展开全部
使用636f707962616964757a686964616f31333332636435WSH(webwork,spring,hibernate)技术,在页面中加载10-20个图片时,因为数据都是在oracle 10g中以blob类型存储,页面代码采用webwork标签iterator遍历集合,iterator标签里写了一个
前台代码如下:
' name="imgId" width="120" height="120" src="/blobUtil/getImg.action?id=" />
后台代码:public String getImg() throws Exception{
BufferedInputStream ins;//取得BLOB的IO流
OutputStream ops;
byte[] bt = null;
getResponse().setContentType("image/JPEG");
Blob bo = bjqeDtRelationService.getBjqeDtRelationChildBlob(imgId);
if (bo == null) return null;
InputStream is = bo.getBinaryStream();
ins = new BufferedInputStream(is);
int bufferSize = (int) bo.length();//取得BLOB的长度
bt = new byte[bufferSize];
ins.read(bt, 0, bufferSize);
getResponse().getOutputStream().write(bt);
ops = getResponse().getOutputStream();
ops.flush();
ops.close();
ins.close();
return null;
}