阅读背景:

Java VUE 使用文件流 实现下载功能

来源:互联网 
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='/go.html?url=${fss}/dcb/getExcel2' >get 流下载</a> 3、浏览器访问: https://localhost:8001/ 1、后端:controller控制器 /** * 导出 --->资产信息 * @return



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: