@RequestMapping("/downloadl")
@ApiOperation(value = "下载模版", notes = "下载模版", produces = "application/json; charset=utf-8")
public ResponseEntity<byte[]> downTemplate(HttpServletResponse response, HttpServletRequest request, String excelName, String fileName) throws IOException {
HttpHeaders headers = new HttpHeaders();
fileName="模板";
headers.setContentDispositionFormData("attachment", URLEncoder.encode(fileName, "utf-8") + ".xlsx");
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM)
StringBuffer pathSb = new StringBuffer(ResourceUtils.CLASSPATH_URL_PREFIX);
pathSb.append("template");
pathSb.append(File.separator).append(fileName).append(".xlsx");
File file = ResourceUtils.getFile(pathSb.toString());
InputStream is=new FileInputStream(file);
byte[] byt = new byte[is.available()];
is.read(byt)
return new ResponseEntity<>(byt, headers, HttpStatus.CREATED);
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-66040.html