弑天下
首先你需要确定附件的类型及名称。然后下载很简单的,根据下载的请求返回response.addHeader ("content-type","application/RFC822");response.addHeader ("Content-Disposition","attachment; filename=word,pdf");OutputStream os = null;try{os = response.getOutputStream (); byte[] data =xxx(数据库的二进制流);
os.write (data);
os.flush ();
os.close ();
} catch (IOException e)
{
e.printStackTrace ();
}这样就能下载下来pdf文件咯;