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

目录
相关文章
|
7月前
|
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. 报错解决
695 0
|
3月前
|
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
93 0
|
7月前
|
设计模式 JavaScript 前端开发
Vue3报错Property “xxx“ was accessed during render but is not defined on instance
Vue3报错Property “xxx“ was accessed during render but is not defined on instance
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 : ‘}‘
124 0
|
7月前
Parsing error: No Babel config file detected for XXXXX
Parsing error: No Babel config file detected for XXXXX
Error: Plugin/Preset files are not allowed to export objects, only functions……
Error: Plugin/Preset files are not allowed to export objects, only functions……
|
JavaScript API
properties starting with “$“,“_“ are not proxied in the Vue instance to prevent conflicts
properties starting with “$“,“_“ are not proxied in the Vue instance to prevent conflicts
112 0
properties starting with “$“,“_“ are not proxied in the Vue instance to prevent conflicts
|
JavaScript
[Vue warn]: Duplicate keys detected: ‘0‘. This may cause an update error.
首先Duplicate keys detected: '0'. This may cause an update error是vue发现key不是唯一的而引发的错误. 译为中文大概是 : 检测到重复键 : '0'. '0'可能会导致一个更新错误. 解决办法网上找的其他也有一些.通过手动进行修改:key进而解决,比如说进行拼接字符串.因为为了解决不报错,而手动修改了数据.个人感觉不应该是这样的.
279 0
[Vue warn]: Duplicate keys detected: ‘0‘. This may cause an update error.
|
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
|
JavaScript
Vue | Property '**' does not exist on type 'unknown'.
Vue | Property '**' does not exist on type 'unknown'.
2218 0