数据库里存储照片的字段是Blob字段,实体定义为String类型,取出该图片并在页面显示 该怎么办
解决方案 »
- ServletContext事件处理的实现问题
- 跪求高手解答,action="install!check.action"
- struts2.0 超链接 传值
- 如何用java编写从网页中抽取信息的工具
- DOM生成XML文件时怎么加如DOCTYPE声明部分?
- 在main()中调用ejb出错
- 输入问题?随机产生数字,再从随机产生的数字中随机产生数字
- 为什么必须用方法的参数final?
- 请问有谁用过APUSIC应用服务器 他和WEBLOGIC从功能上讲有什么区别?
- java.exe就是JVM这种说法对吗
- hibernate getHibernateTemplate() 空指针异常
- struts2标签格式化数字的问题,高手进
读取Blob image =读取数据库的blog;//附件扫描图片
if (image != null) {
try {
byte[] buf = new byte[(int)image.length()];
buf = image.getBytes(1, (int) image.length());
BufferedInputStream pi = new BufferedInputStream(image.getBinaryStream());
response.setContentType("image/jpeg;");
ServletOutputStream out = response.getOutputStream();
response.setContentLength(pi.available());
response.reset();
int bytesRead = 0;
while((bytesRead = pi.read(buf)) != -1) {
out.write(buf, 0, bytesRead);
}
pi.close();
out.flush();
} catch (Exception e) {
e.printStackTrace();
}
}