@RequestMapping("/public/download")
public void download(String id, HttpServletRequest request, HttpServletResponse res) throws IOException{
Attachment att = dbServices.getEntity(Attachment.class, id ) ;
String fileName = att.getFileName();
OutputSteam os = res.getOutputStream() ;
String path = att.getFileDir() + "/" + att.getPhysicalName() ;
try{
res.reset() ;
res.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("GB2312"),"iso-8859-1"));
res.setContentType("application/octet-stream;charset=utf-8");
os.write(FileUtils.readFileToByteArray(new File(path)));
os.flush();
} finally{
if(os != null){
os.close();
}
}
}