problem
Poi-tl in HttpServletResponse export Word garbled problem:
- file name is in Chinese, and the Chinese name is garbled
the exported file to download garbled
reason
Chinese garbled file name:
- No encoding rules for filenames set
file download garbled characters:
Controller layer in RESTful incorrectly uses PostMapping
Solution
file name is garbled:
String attachName = new String(("Xxx.docx").getBytes(), "ISO-8859-1"); response.setHeader("Content-disposition", "attachment;filename=" + attachName);
File download garbled characters:
- The interface exported by Word uses ==GetMapping==
- Use ==Request URL== to get file download
Get Word template path:
Use the InputStream tool class to get the path of the file
// 使用InputStream流获取Word模版 InputStream fis = this.getClass().getResourceAsStream("/template/xxxTemplate.docx");
Summarize
- Learn the usage of the framework according to the framework documentation, and then develop related functions according to the example
- Pay attention to the usage notes and advanced usage in the framework
- Combine advanced usage with project practice and choose the best solution for use
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。