我正在使用 <rich:fileUpload> 组件输入图像,将其转换为字节数组,然后将其存储到 mysql 数据库中。是否有任何组件可以将该字节数组作为图像显示?
我想将 book.getCover 显示为图像:
<rich:fileUpload fileUploadListener="#{bookDetailsBean.coverUploadListener}"
stopButtonClass="file-upload-stop-button"
addButtonClass="file-upload-button"
id="upload" acceptedTypes="jpg, gif, png, bmp" maxFilesQuantity="1"
</rich:fileUpload>
public void coverUploadListener(FileUploadEvent event) {
UploadedFile item = event.getUploadedFile();
byte[] data = item.getData();
book.setCover(data);
}