@GetMapping(“/downloadAccountTemplate”)public Object downloadAccountTemplate(HttpServletResponse response) {
//文件路径
String filePath = “/template/“;
//文件名称
String fileName = “AccountTemplate.xlsx”;
//设置要下载的文件的名称
response.setHeader(“Content-disposition”, “attachment;fileName=” + fileName);
//通知客服文件的MIME类型
response.setContentType(“application/vnd.ms-excel;charset=UTF-8”)_;
try _(_InputStream input = getClass_()_.getResourceAsStream_(_filePath + fileName_)_; OutputStream out = res.getOutputStream_()) {<br /> _byte_[] _b = new byte_[_2048_]_;<br /> int len;<br /> while _((_len = input.read_(_b_)) _!= -1_) {<br /> _out.write_(_b, 0, len_)_;<br /> _}<br /> _return ResponseData._success(_"模板下载成功"_)_;<br /> _} _catch _(_IOException e_) {<br /> _return ResponseData._error(_"模板下载失败"_)_;<br /> _}<br />}_