今天真是被自己的懒惰和复制粘贴给坑惨了...网上有这么一个spring下载文件的最佳实践:@RequestMapping("download") public ResponseEntity<byte[]> download() throws IOE ...
今天真是被自己的懒惰和复制粘贴给坑惨了...
网上有这么一个spring下载文件的最佳实践:
@RequestMapping("download") public ResponseEntity<byte[]> download() throws IOException { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentDispositionFormData("attachment", "xxx.txt"); return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(getDictionaryFile()), headers, HttpStatus.CREATED); }
原标题:复制粘贴出来的悲剧
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。