String file_id = runtime.getParameter("file_id");
String file_name = runtime.getParameter("file_name");
NfsFileBizDelegate fileBiz = new NfsFileBizDelegate();
Session sess = Session.openSession();
try
{
// 替换为response.setContentType("application/x-msdownload");
runtime.getHttpResponse().setContentType("application/x-msdownload");
// response.setHeader("Content-disposition","attachment;filename="+file_name);
runtime.getHttpResponse().setHeader("Content-disposition","attachment; filename="+file_name);
Blob blob = fileBiz.retrieveBLOBObjectByFileId(Long.parseLong(file_id));
if(blob!=null) {
InputStream is = blob.getBinaryStream();
// response.getOutputStream();
BufferedOutputStream bos=new java.io.BufferedOutputStream(runtime.getHttpResponse().getOutputStream());
byte[] b = new byte[((oracle.sql.BLOB)blob).getBufferSize()];
int len = 0;
while((len = is.read(b)) != -1){
bos.write(b,0,len);
bos.flush();
}
bos.close();
is.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
sess.close();
}
runtime 是web框架在运行中获得的,相应的替换为注释代码即可