public ResponseEntity exportSiteList(@RequestParam("task_id") Integer task_id){
//业务逻辑
........
List<List<Object>> data = new ArrayList(); //即将导出数据集合
for(PlatformDataAnnotationVerify obj: records){
String path="";
try {
path = getClass().getResource("/").toURI().getPath();
path=path.substring(0,path.length()-16);
} catch (URISyntaxException e) {
e.printStackTrace();
}
String filename= ExportExcel.exportExcel(heads, data, path);
FileSystemResource fileResource = new FileSystemResource(filename);
ResponseEntity<FileSystemResource> responseEntity = ResponseEntity
.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileResource.getFilename() + "\"")
.body(fileResource);
return responseEntity;
}
SpringBoot返回文件
最新推荐文章于 2024-04-11 12:43:13 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)