文件读取不到
可能是因为maven把word文件压缩了
//pom中添加
<!--不压缩docx文件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>docx</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
读取的时候尽量使用流来读取
try {
//获取模板文档--重点
InputStream is = this.getClass().getClassLoader().getResourceAsStream("word/GeneratedReportDetailWord.docx");
MyXWPFDocument word = new MyXWPFDocument(is);
//替换word中的占位符
WordExportUtil.exportWord07(word , map);
String fileName = map.get("poolName") + "月份打分表.docx";
//导出
response.setHeader("content-disposition","attachment;filename="+new String(fileName.getBytes(),"ISO8859-1"));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
word.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}