首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Error resolving template [excel/readExcel], template might not exist or might no

Error resolving template [excel/readExcel], template might not exist or might no

原创
作者头像
刘大猫
发布2025-09-19 20:23:58
发布2025-09-19 20:23:58
180
举报
文章被收录于专栏:JAVA相关JAVA相关

@toc

错误场景

在使用阿里巴巴的easyexcel,调用后台接口读取指定excel文件进行输出打印时报错

代码语言:java
复制
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

代码语言:java
复制
<!--读取excel文件-->
<dependency>
     <groupId>com.alibaba</groupId>
     <artifactId>easyexcel</artifactId>
     <version>2.2.6</version>
 </dependency>

Controller

代码语言:java
复制
//读取指定的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文件如下

解决方案2种

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

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

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 错误场景
  • 代码如下
  • 解决方案2种
    • 第一种方案:@Controller => @RestController
    • 第二种方案:方法添加注解 @ResponseBody
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档