org.thymeleaf.exceptions.TemplateInputException: Error resolving template报错


遇到二次,第一次是刚刚学的时候,都是一个原因,而且又看到网上的解决方法

又不相信懒得C,结果找了我半天

(主要自己之前没加这个也可以,但是突然就不可以了,还是抱着试一试)

在controller层请求处理完了返回时,没有使用@RestController或@ResponseBody而返回了非json格式


这种情况下返回的数据thymeleaf模板无法解析,直接报错,本人正式因为这个原因才报错。

解决方案:可以将@Controller换成@RestController,不过需要注意有没有其他的方法返回了html页面,会导致返回的不是页面而是字符串;最好的方法就是在你所请求的方法上面加一个@ResponseBody即可。

在你的controller层对应的方法返回html路径及名称时,在前面多加了一个/ 。


例如return "/index",正式这个/导致报错的,解决:去掉返回前面的/即可,例如return "/index" 。

在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错。


解决办法如下:

在application.yml中添加以下配置

spring.thymeleaf.content-type: text/html
spring.thymeleaf.cache: false
spring.thymeleaf.mode: LEGACYHTML5

再在pom.xml 添加以下依赖

<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>

资源文件的路径被修改,如果你其他的请求都正常返回则可忽略这条。


解决:在pom.xml文件的中加入

<resource>
<directory>src/main/resources</directory>
</resource>

这就是我收集到的报错了

org.thymeleaf.exceptions.TemplateInputException: Error resolving template 报错的更多相关文章

  1. org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/ template might not exist or might not be accessible by any of the configured

    异常现象:在本地打包部署完全没有问题,资源文件也都可以映射上,但是打包成jar包部署到服务器上时,就一直报异常,异常信息如下: 严重: Servlet.service() for servlet [d ...

  2. org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/home/index2", template might not exist or might not be accessible by any of the configured Template Resolvers

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/home/index2", ...

  3. springboot报 org.thymeleaf.exceptions.TemplateInputException: Error resolving template "succeed";

    --------------------- 本文转自 林晓风 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/Lin_xiaofeng/article/details/ ...

  4. Thymeleaf 模板使用 Error resolving template "/home", template might not exist or might not be accessible by any of the

    和属性文件中thymeleaf模板的配置相关 1.配置信息 spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix= ...

  5. kendo模板 Uncaught Error: Invalid template:' 报错

    I was having a problem with a grid toolbar template because of a # in a hrefWorked out that I needed ...

  6. spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template "admin/verifyPassword ...

  7. spring boot 使用thymeleaf模版 报错:org.thymeleaf.exceptions.TemplateInputException

    错误: org.thymeleaf.exceptions.TemplateInputException: Error resolving template "Hello", tem ...

  8. Error resolving template,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 at o ...

  9. exception processing, template error resolving template

    错误信息:Exception processing template “/view/df”: Error resolving template “/view/df”, template might n ...

随机推荐

  1. 为什么需要OLAP DSL?

    OLAP(On-Line Analytical Processing,联机分析处理)是大数据场景中,数据价值探索与挖掘的重要环节.这个领域内,开源社区呈现百花齐放的现象,Elasticsearch.D ...

  2. java数据结构——二叉树(BinaryTree)

    前面我们已经学习了一些线性结构的数据结构和算法,接下来我们开始学习非线性结构的内容. 二叉树 前面显示增.删.查.遍历方法,完整代码在最后面. /** * 为什么我们要学习树结构. * 1.有序数组插 ...

  3. 蓝桥杯 algo122 未名湖的烦恼 简单题

    #include <iostream> using namespace std; int m, n, ans; void solve(int m, int n, int cnt) { &a ...

  4. Vue Element 导航子路由不选中问题

    首先说下遇到的问题 1.进入嵌套路由,当前父导航无法高亮显示 2.页面刷新后导航重置问题 3.在嵌套路由刷新页面也会导致导航重置问题 接下来是解决方案: elementUI 里面有个属性 defaul ...

  5. Maven 梳理 - 常用三种archetype说明

    archetype:原型的意思,可理解为Maven项目模板工具包 常用archetype 1.cocoon-22-archetype-webapp 2.maven-archetype-quicksta ...

  6. redis分布式锁-WATCH锁(废弃)

    使用watch构建锁的代码结构.(最着负载不断增加,系统完成一次加锁操作,重试次数不断加大) pine=conn.pineline while pine.watch if xxx pine.unwat ...

  7. linux 防火墙相关命令

    1.系统命令systemctl start firewalld #启动 systemctl status firewalld #查看运行状态 systemctl stop firewalld #关闭 ...

  8. Flask基础(06)-->视图常用逻辑

    Flask基础(06)-->视图常用逻辑 返回json 重定向:url_for 自定义状态码 返回json:在使用 Flask 写一个接口时候需要给客户端返回 JSON 数据,在 Flask 中 ...

  9. [Vjudge][POJ][Tony100K]搜索基础练习 - 全题解

    目录 POJ 1426 POJ 1321 POJ 2718 POJ 3414 POJ 1416 POJ 2362 POJ 3126 POJ 3009 个人整了一些搜索的简单题目,大家可以clone来练 ...

  10. redis实践 —— redisReply简析

    redisReply 定义如下: /* This is the reply object returned by redisCommand() */ typedef struct redisReply ...