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返回文件
最新推荐文章于 2025-01-23 11:56:38 发布
21万+

被折叠的 条评论
为什么被折叠?



