@RequestMapping("downloadTemplate")
public void downloadTemplate() throws IOException{
InputStream in = null;
OutputStream out = null;
try {
this.getResponse().reset();
this.getResponse().setContentType("application/x-msdownload");
this.getResponse().setHeader("Content-Disposition", "attachment;filename="+new String("投标清单模板.xls".getBytes("gb2312"), "ISO8859-1" ));
in = new FileInputStream(this.getRequest().getServletContext().getRealPath("/")+File.separator+"jsp"+File.separator+"model"+File.separator+"模板.xls");
out = this.getResponse().getOutputStream();
//写文件
int b;
while((b=in.read())!= -1){
out.write(b);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
in.close();
out.close();
}
}
springMVC文件下载
最新推荐文章于 2024-03-17 16:19:26 发布