Problem occurs 1:
Use POI to export Excel under Spring MVC Framework, set export file name: Response.setheader ("Content-disposition", "Attachment;filename=" +sourceid+ "_" + datestring+ ". xls");
When this method is used to catch a package test, it shows that the bug URL is not valid.
Workaround: String filenmae = Urlencoder.encode for "attachment;filename=" +sourceid+ "_" +datestring+ ". xls" ("attachment; Filename= "+sourceid+" _ "+datestring+". xls ", StandardCharsets.UTF_8.displayName ()); Again Response.setheader ("Content-disposition", Filenmae);
However, a new problem occurs 2:poi when you export Excel, the export file name is the action method name.
Workaround: Use new String (byte[], "utf-8");
String fileName = "Attachment;filename=" +sourceid+ "_" +datestring+ ". xls";
Response.setheader ("Content-disposition", New String (Filename.getbytes (), "Utf-8"));
Final Solution: Grab the package test pass.
Java POI export Excel response.setheader Settings export file name grab package illegal and process export FileName as action method name