@GetMapping("/download")
public void download(HttpServletResponse response)throws Exception{
ClassPathResource classPathResource = new ClassPathResource("templates\\Topic_Template.xlsx");
InputStream inputStream = classPathResource.getInputStream();
//生成目标文件
File somethingFile = File.createTempFile("Topic_Template", ".xlsx");
try {
FileUtils.copyInputStreamToFile(inputStream, somethingFile);
} finally {
IOUtils.closeQuietly(inputStream);
}
InputStream in = new FileInputStream(somethingFile);
response.setHeader("Content-Disposition","attachment;filename=" + new String(("Topic_Template.xlsx").getBytes("gb2312"),"iso-8859-1"));
response.setContentType("application/octet-stream; charset=utf-8");
response.addHeader("Content-Length",in.available()+"");
ServletOutputStream out=response.getOutputStream();
IOUtils.copy(in, out);
in.close();
out.close();
}