当我们遇到"500 Internal Server Error"这个的消息时,意味着服务器遇到了意外情况,无法完成请求。
在使用EasyExcel的时候出现这个问题。我们根据官网配置的HttpServletResponse中设置的header里
java
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename="+fileName);
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), BudgetForm.class).build();
如果出现 500 Internal Server Error问题,删除fileName,不传名称过去就可以了
java
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=");
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), BudgetForm.class).build();
正常访问下载