org.thymeleaf.exceptions.TemplateInputException: Error resolving template 报错
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 报错的更多相关文章
- 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 ...
- 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", ...
- springboot报 org.thymeleaf.exceptions.TemplateInputException: Error resolving template "succeed";
--------------------- 本文转自 林晓风 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/Lin_xiaofeng/article/details/ ...
- 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= ...
- 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 ...
- spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "admin/verifyPassword ...
- spring boot 使用thymeleaf模版 报错:org.thymeleaf.exceptions.TemplateInputException
错误: org.thymeleaf.exceptions.TemplateInputException: Error resolving template "Hello", tem ...
- 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 ...
- exception processing, template error resolving template
错误信息:Exception processing template “/view/df”: Error resolving template “/view/df”, template might n ...
随机推荐
- hadoop之mapreduce详解(进阶篇)
上篇文章hadoop之mapreduce详解(基础篇)我们了解了mapreduce的执行过程和shuffle过程,本篇文章主要从mapreduce的组件和输入输出方面进行阐述. 一.mapreduce ...
- c3p0配置记录
官方文档 : http://www.mchange.com/projects/c3p0/index.html <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数.Default: 3 ...
- 【SQL server】SQL Server 触发器
触发器是一种特殊类型的存储过程,它不同于之前的我们介绍的存储过程.触发器主要是通过事件进行触发被自动调用执行的.而存储过程可以通过存储过程的名称被调用. Ø 什么是触发器 触发器对表进行插入.更新.删 ...
- 06-border
边框 border:边框,描述盒子的边框 边框的三要素:粗细 线性样式 颜色 例如:border:1px solid red: 如果颜色不写,默认是黑色:如果粗细不写,不显示边框:如果只写线性样式,默 ...
- TensorFlow2.0(五):张量限幅
.caret, .dropup > .btn > .caret { border-top-color: #000 !important; } .label { border: 1px so ...
- Python3 GUI开发(PyQt)安装和配置
Python3 GUI开发(PyQt5)安装和配置: 下载安装好Miniconda3, 并且安装好jupyter 注意:最好关闭360杀毒软件或者把cmd加入信任,否则运行activate会有问题. ...
- Scala 学习笔记之集合(1)
package com.citi.scala object CollectionDemo { def main(args: Array[String]): Unit = { /** * List */ ...
- 浅谈MVC&MTV设计模式
在目前基于Python语言的几十个Web开发框架中,几乎所有的全栈框架都强制或引导开发者使用MVC设计模式.所谓全栈框架,是指除了封装网络和线程操作,还提供HTTP.数据库读写管理.HTML模板引擎等 ...
- 访问http接口时返回502 Bad Getway什么原因怎么解决
使用 httpclient 工具通过代理服务器请求第三方http 接口,多次返回 502 Bad Getway,少数返回正常. 502 Bad Getway是什么意思? 502 Bad Gateway ...
- 超详细的FreeRTOS移植全教程——基于srm32
### 准备 在移植之前,我们首先要获取到FreeRTOS的官方的源码包.这里我们提供两个下载链接: > 一个是官网:http://www.freertos.org/ > 另外一个是代码托 ...