Error resolving template [excel/readExcel], template might not exist or might not be accessible by

简介: Error resolving template [excel/readExcel], template might not exist or might not be accessible by

1.jpeg

错误场景

在使用阿里巴巴的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文件如下
image.png

解决方案2种

第一种方案:@Controller => @RestController

第二种方案:方法添加注解 @ResponseBody

目录
相关文章
|
6月前
|
JavaScript
Property “selectedItemIndex“ was accessed during render but is not defined on instance. 报错解决
Property “selectedItemIndex“ was accessed during render but is not defined on instance. 报错解决
665 0
|
2月前
|
JSON 前端开发 Java
template might not exist or might not be accessible by any of the configured Template Resolvers
template might not exist or might not be accessible by any of the configured Template Resolvers
60 0
|
3月前
ESLint—— Failed to load config "standard" to extend from
ESLint—— Failed to load config "standard" to extend from
78 0
|
4月前
|
JavaScript
Cannot read properties of undefined (reading ‘$router‘)
Cannot read properties of undefined (reading ‘$router‘)
|
6月前
|
JavaScript 前端开发
ESLint—— Failed to load config “standard“ to extend from
ESLint—— Failed to load config “standard“ to extend from
191 0
|
11月前
Error: Plugin/Preset files are not allowed to export objects, only functions……
Error: Plugin/Preset files are not allowed to export objects, only functions……
|
前端开发 数据库
Failed to load response dataNo data found for resource with given identifier
Failed to load response dataNo data found for resource with given identifier
1617 0
|
JavaScript 算法 前端开发
Property xxx was accessed during render but is not defined on instance
目前el-form的model主要用表单验证的,也就是配合el-form的rules和el-form-item的prop来使用的。不信的话,你可以增加一个rules和prop(为了调用验证方法,也el-form也加一个ref属性,相当于id或者class选择器的意思),但是不写model,然后验证的话,会提示缺少model,导致无法验证成功。
Property xxx was accessed during render but is not defined on instance
|
Java
The type XXX cannot be resolved. It is indirectly referenced from required .class files
The type XXX cannot be resolved. It is indirectly referenced from required .class files
131 0