@RequestMapping("downLoadLicence")
public ResponseEntity<byte[]> download(HttpServletRequest request) throws IOException {
try {
File file = new File("/home/www/stbcms/web/licence");
byte[] body = null;
InputStream is = new FileInputStream(file);
body = new byte[is.available()];
is.read(body);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Disposition", "attchement;filename=" + "licence");
HttpStatus statusCode = HttpStatus.OK;
ResponseEntity<byte[]> entity = new ResponseEntity<byte[]>(body, headers, statusCode);
return entity;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
springmvc返回文件流下载
最新推荐文章于 2023-12-11 11:38:18 发布