gpt4 book ai didi

jsf-2 - p :graphicImage not rendered in Internet Explorer 10+

转载 作者:行者123 更新时间:2023-12-02 03:17:31 26 4
gpt4 key购买 nike

我正在尝试显示带有动态内容的 p:graphicImage。我的观点:

<p:graphicImage value="#{loginBean.loginImage}" />

支持 bean(Spring Bean/Singleton Scope)

public StreamedContent getLoginImage() throws IOException
{
if (FacesContext.getCurrentInstance().getCurrentPhaseId() == PhaseId.RENDER_RESPONSE)
{
return new DefaultStreamedContent();
}

String loginImage;

if (developmentState)
{
loginImage = "dev.jpg";

} else
{
loginImage = "prod.jpg";
}

final byte[] bytes = ... load bytes
return new DefaultStreamedContent(new ByteArrayInputStream(bytes), "image/jpg");
}

这在 Firefox/Chrome 中运行良好。 但它在 IE 10+ 中失败呈现的不是真实图像而是空框

我的登录页面使用:

<h:head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
</f:facet>
</h:head>

页面已呈现。 IE 中仅缺少图像(Firefox/Chrome 正确呈现)。即使启用了 TRACE 级别,服务器端也没有错误。

即:

<img id="j_idt10" alt="" src="/appContext/javax.faces.resource/dynamiccontent.properties.xhtml?ln=primefaces&amp;pfdrid=ufpDFHhNpCx9dNk92OfD7uAPP6LjduXzuDwZf73cSco%3D&amp;pfdrt=sc&amp;pfdrid_c=true">

Chrome :

<img id="j_idt10" src="/appContext/javax.faces.resource/dynamiccontent.properties.xhtml?ln=primefaces&amp;pfdrid=ufpDFHhNpCx9dNk92OfD7uAPP6LjduXzuDwZf73cSco%3D&amp;pfdrt=sc&amp;pfdrid_c=true" alt="">

火狐:

<img alt="" src="/appContext/javax.faces.resource/dynamiccontent.properties.xhtml?ln=primefaces&amp;pfdrid=ufpDFHhNpCx9dNk92OfD7uAPP6LjduXzuDwZf73cSco%3D&amp;pfdrt=sc&amp;pfdrid_c=true" id="j_idt10">

IExplore DEV 控制台说:

HTTP    GET 200 44,29 KB    16 ms   <img> for image
/appConctext/javax.faces.resource/dynamiccontent.properties.xhtml?ln=primefaces&pfdrid=ufpDFHhNpCx9dNk92OfD7uAPP6LjduXzuDwZf73cSco%3D&pfdrt=sc&pfdrid_c=true

任何帮助将不胜感激。谢谢

最佳答案

受 BalusC 评论的启发,我在 DefaultStreamedContent 部分添加了 Content-Type header "image/jpeg"

return new DefaultStreamedContent(new ByteArrayInputStream(bytes), "image/jpg");

注意:“image/jpg”不适用于 Internet Explorer

关于jsf-2 - p :graphicImage not rendered in Internet Explorer 10+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35742080/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com