嗨,我正在将图像保存到数据库中,我将图像作为多部分并尝试转换为Blob类型。我做这个方法:
Blob blob=Hibernate.getLobCreator(sessionFactory.getCurrentSession()).createBlob(multipartFile.getInputStream(),multipartFile.getSize());
Run Code Online (Sandbox Code Playgroud)
但是得到Nullpointer Exception While Executing. 该文件无法将多部分转换为Blob任何其他方法将图像保存到数据库中。
MultipartFile savedFile;
savedFile=itemView.getImgFile();//file from model attribute
Blob blob=Hibernate.createBlob(savedFile.getInputStream()); // hibernate method for create blob
//Save method will be call here
Run Code Online (Sandbox Code Playgroud)
http://viralpatel.net/blogs/tutorial-save-get-blob-object-spring-3-mvc-hibernate/ 我按照上面的教程进行操作
| 归档时间: |
|
| 查看次数: |
9201 次 |
| 最近记录: |