--------------------- 本文转自 林晓风 的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] 929. Unique Email Addresses (easy)

    统计有几种邮箱地址. 邮箱名类型:local@domain 规则:1. local中出现"."的,忽略. a.bc=abc 2. local中出现"+"的,+以 ...

  2. vijos P1911 珠心算测验

    #include<iostream> using namespace std; int main() { int n; int sum = 0; int num[200]; cin > ...

  3. FJNUOJ 1002 画葫芦。。

    画图就是..找..规..律 #include <iostream>using namespace std;int main(){ int T; cin>>T; while(T- ...

  4. Node.js实现简易的获取access_token

    还是老样子,在自学node.js的道路上走得坑坑洼洼,按住了躁动的自己,调整好心情 ,ready........Go....! 首先在项目里新建config.json,其中 appid 与 appsc ...

  5. centOS7 安装mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar

    在虚拟机上安装mysql走了不少弯路,在此备份... 首先感谢下这几篇博客提供的帮助: https://www.cnblogs.com/pythonal/p/6141516.html http://b ...

  6. HTTP,TCP,IP详解

    互联网协议包含了上百种协议标准,但是最重要的两个协议是TCP和IP协议,所以,大家把互联网的协议简称TCP/IP协议. 通信的时候,双方必须知道对方的标识,好比发邮件必须知道对方的邮件地址.互联网上每 ...

  7. web设计_8_数据表格内容样式分离

    1.页面需要用到table的时候,样式重置CSS要设置: table{ border-collapse: collapse; border-spacing:; } 2. HTML结构 <tabl ...

  8. jquery 实现图片上传,并在前端显示出来

    目前遇到一个图片上上传的需求,突然发现,原来之前都没有做过此种类型的需求,以下是需求样式: 看到需求后之所以有点懵,是因为我接触到的文件上传,一般都是按钮类型的,例如以下这种: 深呼吸,好好想一下,整 ...

  9. MemCached的工具类。获取cached中的所有key

    package com.ibs.auth.controller; import java.io.UnsupportedEncodingException; import java.util.Date; ...

  10. drf之序列化

    在django视图中使用serializer 只是使用serializer类编写API视图,没有用到REST框架 app01下的models.py from django.db import mode ...