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

目录
相关文章
|
4月前
|
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. 报错解决
485 0
|
1天前
|
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
7 0
|
4月前
|
JavaScript
解决报错did you register the component correctly? For recursive components, make sure to provide the “na
解决报错did you register the component correctly? For recursive components, make sure to provide the “na
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
106 0
|
9月前
|
JavaScript
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
报错 An error happened during template parsing (template: “ServletContext resource [/shiroTest.html]“)
报错 An error happened during template parsing (template: “ServletContext resource [/shiroTest.html]“)
|
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
115 0
|
应用服务中间件 Android开发
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
129 0
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name: