原因分析:下载文件后文件流关闭,但返回了成功和失败的Result。
解决:将return Result.operating("导出成功!", true, ResultCode.SUCCESS);改为return null;
@PostMapping("/exportExcel")public Result exportExcelStock(@RequestBody DrugStockVO drugStockVO, HttpServletResponse response) throws Exception { Result result = drugStockService.getAllList(drugStockVO); List<DrugStock> list = (List<DrugStock>) result.getData(); .... String str = "库存信息"; ExcelUtils.exportExcel(str, str, str, list, response); return Result.operating("导出成功!", true, ResultCode.SUCCESS); }
修改为:
@PostMapping("/exportExcel")public Result exportExcelStock(@RequestBody DrugStockVO drugStockVO, HttpServletResponse response) throws Exception { Result result = drugStockService.getAllList(drugStockVO); List<DrugStock> list = (List<DrugStock>) result.getData(); ... String str = "库存信息"; ExcelUtils.exportExcel(str, str, str, list, response); return null; }