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

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

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

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

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

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

3. 在使用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>

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

解决:在pom.xml文件的<build></build>中加入.

<resource>

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

</resource>

    

springboot报 org.thymeleaf.exceptions.TemplateInputException: Error resolving template "succeed";的更多相关文章

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

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template报错 遇到二次,第一次是刚刚学的时候,都是一个原因,而 ...

  2. 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 ...

  3. 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", ...

  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. spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException

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

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

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

  7. 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 ...

  8. exception processing, template error resolving template

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

  9. Error resolving template [xxx], template might not exist or might not be exist

    Springboot+thymeleaf+mybatis 抛Error resolving template [xxx], template might not exist的异常 原因是我们在pom. ...

随机推荐

  1. [leetcode] 234. Palindrome Linked List (easy)

    原题 回文 水题 function ListNode(val) { this.val = val; this.next = null; } /** * @param {ListNode} head * ...

  2. Linux卸载MySql——ubuntu版

    卸载mysql 1)删除mysql的数据文件 sudo rm /var/lib/mysql/ -R 2)删除mqsql的配置文件 sudo rm /etc/mysql/ -R 3)自动卸载mysql的 ...

  3. linux基础命令期末考试总结

    1.关闭防火墙:service iptables stop 2.启动防火墙:service iptables start 3.mount命令:挂载某一设备使之成为某个目录名称 4.NFS服务:linu ...

  4. 第二章: Java总结

    第二章笔记 什么是变量:变量代表一块内存区域,变量类型不一样,这一块内存的大小也不一样.#在编程语言里面,你可以通过定义变量,向内存里添加数据或者修改内存已有的数据.说白了,变量就是代表程序运行时存放 ...

  5. Nginx搭建详细

    Linux 安装Nginx搭建详细内容 进入:/usr/java/nginx位置下载nginx: wget et http://nginx.org/download/nginx-1.8.0.tar.g ...

  6. js实现字符串转JSON格式

    在浏览器前端实现字符串转JSON格式,有多种方法,总结如下: 方法1. js函数,eval() 语法: var obj = eval ("(" + txt + ")&qu ...

  7. Nginx安装(详细版本)

    Nginx安装文档 前言: 最近,系统部署人员那边,让我们给写一个傻瓜式的Nginx安装过程.所以就有了这个文档,本着独乐乐不如众乐乐,就分享一下.我觉得对入门小白来说,有图,乃至运行过程图,是很重要 ...

  8. WPF:Task与事件在下载同步界面中的应用

    //设置一个下载事件类,可传输一个字符串  public class DownloadEventArgs:EventArgs     {         public string id { get; ...

  9. java 动手动脑7

    ---恢复内容开始--- 一.动手动脑:多层的异常捕获-1 阅读以下代码(CatchWho.java),写出程序运行结果: ArrayIndexOutOfBoundsException/内层try-c ...

  10. BootStrap实现简单响应式导航菜单

    用BootStrap实现响应式导航栏,我会对其中的一些样式进行说明.   先上代码,是一个很简单的Demo. <!doctype html> <html> <head&g ...