Java VUE 使用文件流 实现下载功能
1、后端:controller控制器/*** 导出 --->资产信息* @return* @throws IOException* @throws DbException*/@RequestMapping(value = "/getExcel2",method = RequestMethod.GET)@R...
·
1、后端:controller控制器
/**
* 导出 --->资产信息
* @return
* @throws IOException
* @throws DbException
*/
@RequestMapping(value = "/getExcel2",method = RequestMethod.GET)
@ResponseBody
public byte[] aa(HttpServletResponse response){
byte[] bytes = null;
try {
String bmid = "0000000091";
String bmmc = "服务部";
List<String> addStatisticalTypeList = new ArrayList<>();
List<String> reduceStatisticalTypeList = new ArrayList<>();
List<String> standardList = new ArrayList<>();
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
String fileName = URLEncoder.encode("fss.xlsx","utf-8");
response.setHeader("Content-Disposition","attachment; fileName=\""+fileName+"\"");
bytes = dcbService.getExcel(bmid,bmmc,standardList,addStatisticalTypeList,reduceStatisticalTypeList);
} catch (IOException e) {
e.printStackTrace();
} catch (DbException e) {
e.printStackTrace();
}finally {
return bytes;
}
}
2、前端:
<a :href='${fss}/dcb/getExcel2' >get 流下载</a>
3、浏览器访问: http://localhost:8001/
更多推荐
已为社区贡献7条内容
所有评论(0)