首页 > 其他分享 >报错:No converter for [class com.ljxx.model.Result] with preset Content-Type ‘application/octet-stream

报错:No converter for [class com.ljxx.model.Result] with preset Content-Type ‘application/octet-stream

时间:2022-09-26 18:46:01浏览次数:58  
标签:UTF converter exportExcel 报错 Result str return response result

原因分析:下载文件后文件流关闭,但返回了成功和失败的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;
    }

 

标签:UTF,converter,exportExcel,报错,Result,str,return,response,result
From: https://www.cnblogs.com/zwh0910/p/16731960.html

相关文章