//下载resource文件夹下面的document文件夹下的模板
public JsonList orderDownloadTemplate(String strJson,String token,JsonList json)
throws Exception{
String fn = new String("文件名.xls".getBytes("GBK"), "iso8859-1");
String filePath = this.getClass().getClassLoader().
getResource("document").getPath();//获取文件路径
filePath = filePath + "/orderStaffTemplate.xls";
getResponse().setContentType("APPLICATION");
getResponse().setHeader("Content-Disposition",
"attachment; filename=" + fn);
File file=new File(filePath);
FileInputStream fis = new FileInputStream(file);
byte[] bytesArray = new byte[(int) file.length()];
fis.read(bytesArray);
fis.close();
getResponse().getOutputStream().write(bytesArray);
return null;
}
spring boot下载文件
最新推荐文章于 2024-06-27 11:00:34 发布