@GetMapping("/export")
public ResponseEntity<Object> export(String fileUrl) throws Exception {
Resource file = new FileSystemResource(fileUrl);
try {
return ResponseEntity
.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" +
URLEncoder.encode(fileName, "UTF-8") +
";filename*=utf-8''"+URLEncoder.encode(fileName, "UTF-8") + "\"")
.body(file);
} catch (Exception e) {
return null;
}
}
java下载文件,解决不同内核浏览器下载出现文件名中文乱码的问题
最新推荐文章于 2022-07-18 15:00:51 发布