图形图像未在 Primefaces 中呈现流式内容 [英] graphicimage not rendering streamedcontent in Primefaces
问题描述
我正在使用流内容来呈现从 JSF 发送的字节,然后将其作为流内容发回,如下所示:
I'm using streamedcontent to render a byte sent from JSF then send it back as a streamed content as following:
<p:graphicImage value="#{manage.bytesToStreamedContent(car.image)}"/>
其中 image 是存储在数据库中的图像的字节数组
where image is the byte array of the image stored in the database
支持bean:
public StreamedContent bytesToStreamedContent(byte[] bytes)
{
InputStream is = new ByteArrayInputStream(bytes);
StreamedContent image = new DefaultStreamedContent (is, "image/jpeg");
return image;
}
但是我没有在 JSF 页面中获取图像.我在服务器日志中收到此消息:
But I'm not getting the image in the JSF page. I got this message appearing in the server log:
警告:JSF1091:找不到文件动态内容的 MIME 类型.要解决此问题,请将 MIME 类型映射添加到应用程序 web.xml.
WARNING: JSF1091: No mime type could be found for file dynamiccontent. To resolve this, add a mime-type mapping to the applications web.xml.
和:
SEVERE: Error in streaming dynamic resource.
你能帮我解决这个问题吗,我找不到关于这个问题的任何有用信息
can you please help me out here, I cant find any useful info regarding this issue
附注:
我正在使用以下库:
莫哈拉 2.1.3
PrimeFaces 3.1.1
PrimeFaces 3.1.1
玻璃鱼 3.1
推荐答案
找到问题所在.问题不在于图形图像.这是因为图形图像标记正在动态加载(尝试从数据表加载时出现类似问题).动态图像不能直接在数据表或数据网格中呈现.(解决方法是分配一个参数并从 id 中获取图像).
Found where the problem was. The problem wasn't in the graphicimage. It was because the graphicimage tag is being loaded dynamically (similar issue when trying loading from datatable). Dynamic images cannot be rendered directly in datatable or datagrid. (Workaround is to assign a param and bring the images from the id).
然而,解决方案是这里
这篇关于图形图像未在 Primefaces 中呈现流式内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!