图形图像无法渲染Primefaces中的streamedcontent [英] graphicimage not rendering streamedcontent in Primefaces

查看:120
本文介绍了图形图像无法渲染Primefaces中的streamedcontent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用streamedcontent呈现从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

PS:

我使用以下库:

Mojarra 2.1.3

Mojarra 2.1.3

PrimeFaces 3.1.1

PrimeFaces 3.1.1

玻璃鱼3.1

推荐答案

找到问题所在.问题不在图形图像中.这是因为graphicimage标记是动态加载的(尝试从数据表加载时出现类似问题).动态图像不能直接在数据表或数据网格中呈现. (解决方法是分配一个参数,并从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中的streamedcontent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆