--------------------- 本文转自 林晓风 的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_32

    LeetCode 32 题目描述: 给定一个只包含 '(' 和 ')' 的字符串,找出最长的包含有效括号的子串的长度. 示例 1: 输入: "(()" 输出: 2 解释: 最长有效 ...

  2. Java 读写 excel 实战完全解析

    本文微信公众号「AndroidTraveler」首发. 背景 时值毕业季,很多毕业生初入职场. 因此,这边也写了一些新手相关的 Android 技术点. 比如上一篇的 Android 开发你需要了解的 ...

  3. 【MySQL】(一)MySQL 体系结构和存储引擎

    1.1.定义数据库和实例 数据库:物理操作系统文件或其他形式文件类型的集合.在MySQL数据库中,数据库文件可以是frm.MYD.MYI.ibd结尾的文件. 实例:MySQL数据库由后台线程以及一个共 ...

  4. JAVA项目从运维部署到项目开发(五. Nginx)

    <Nginx与Nginx-rtmp-module搭建RTMP视频直播和点播服务器>一文简单介绍了关于直播数据流的nginx相关配置,下面简单介绍下各种项目如何配置nginx. web项目. ...

  5. CentOS7 升级 Python2.x 到 Python3.x

    CentOS 7 中默认安装了 Python,版本比较低(2.7.5),为了使用新版 3.x,需要对旧版本进行升级.由于很多基本的命令.软件包都依赖旧版本,比如:yum.所以,在更新 Python 时 ...

  6. 如何实现Kali linux系统下的U盘启动(小白指导)

    一.准备工作: 声明:这个“操作”并不会影响你原装的系统,真正的即插即用的哦. (1)4GB的U盘<读写速度比较快的> (2)Kali linux镜像文件 (3)软件Universal-U ...

  7. IO-Java实现文件的复制

    public class FileCopy { public static void main(String[] args) throws IOException { // 1.创建一个字节输入流对象 ...

  8. 实现跳转的jsp小例子

    <%@page import="java.io.UnsupportedEncodingException"%> <%@ page language="j ...

  9. 【Android】Theme.AppCompat.Light 问题

    Android 开发的 styles.xml 文件中遇到了这个问题: <style name="AppBaseTheme" parent="Theme.AppCom ...

  10. 利用dockerfile 安装一个nginx-1.14.1

    FROM docker.io/centos MAINTAINER jim 107420988@qq.com ENV TZ "Asia/Shanghai" #ENV TERM xte ...