Spring mvc 导出EXecl 解决getOutputStream() has already been called for this response,
It can be exported normally, but the console is reporting an error. I found a lot of methods in Baidu, but it doesn't work. If you see it, you can try this method to see if it can be solved.
Pay code:
error code:
SwpscService swpscService = (SwpscService) SpringContextUtil.getBean("SwpscService");
mav.addObject("pageobj",swpscService.serachList2(pb));
if(pb.getOthersql8().equals("P")){
ExcelExport excelExport=new ExcelExport();
excelExport.Excelexport(request, response, pb.getResultList());
}
mav.setViewName("Order_FH_tongji");
return mav;
Inside the method of excelExport.Excelexport;
out = response.getOutputStream();
will report an error
Solution:
if(pb.getOthersql8().equals("P")){
ExcelExport excelExport=new ExcelExport();
excelExport.Excelexport(request, response, pb.getResultList());
return null;
}
mav.setViewName("Order_FH_tongji");
return mav;
Just return a null;
Of course, this can only be adaptable, not a panacea