我从数据库加载了一个图像 byte[]
。
有谁有一个关于如何将其变成 StreamedContent
的 Bean 示例吗?对象并在 <p:graphicImage value="#{bean.image}"/>
中使用它?
谢谢。
最佳答案
@Named
public class ImageBean {
private StreamedContent image;
@PostConstruct
public void init() {
image = new DefaultStreamedContent(new ByteArrayInputStream(byteArray)); // your byte array
}
// setter and getter for image omitted
}
然后您在 xhtml 页面中的 p:graphicImage
元素上调用 #{imageBean.image}
关于java - 将字节数组加载到 p :graphicImages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40966386/