错误场景
在使用阿里巴巴的easyexcel,调用后台接口读取指定excel文件进行输出打印时报错
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [excel/readExcel], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.14.RELEASE.jar:3.0.14.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.14.RELEASE.jar:3.0.14.RELEASE]
代码如下
pom.xml
<!--读取excel文件-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.6</version>
</dependency>
Controller
//读取指定的Excel
@RequestMapping(value = "/readExcel")
public List<Teacher> readExcel() {
String fileName = "C:\\Users\\211145187\\Desktop\\fsdownload\\details (1).xls";
TeacherListener studentListener = new TeacherListener();
EasyExcel.read(fileName, Teacher.class, studentListener).sheet().doRead();
return studentListener.getTeacherList();
}
读取的excel文件如下