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. 初学者-asp.net三层架构

    一.概述: 通常意义上的三层架构就是将整个业务应用划分为:表现层(UI).业务逻辑层(BLL).数据访问层(DAL).区分层次的目的即为了“高内聚,低耦合”的思想.是一种总体设计的思想. 1.表现层( ...

  2. fslove - Matlab求解多元多次方程组

    fslove - Matlab求解多元多次方程组 简介: 之前看到网上的一些资料良莠不齐,各种转载之类的,根本无法解决实际问题,所以我打算把自己的学到的总结一下,以实例出发讲解fsolve. 示例如下 ...

  3. 转:sqlserver 存储毫秒23:59:59.999变成第二天00:00:00.000

    因为,在SQL SERVER中DATETIME表示的时间为00:00:00到23:59:59.997,它的时间精度为1/300秒,在使用时会舍入到舍入到 .000..003 或 .007 秒三个增量. ...

  4. elastic集群单节点停机维护

    为了elastic时时提供服务,需要elastic至少状态维持在yellow状态.所有,维护时需要依次对elastic单个节点进行维护. 操作步骤如下: 1.停止elastic的自动分配功能 curl ...

  5. 基于MFCC的语音数据特征提取概述

    1. 概述 语音是人类之间沟通交流的最直接也是最快捷方便的一种手段,而实现人类与计算机之间畅通无阻的语音交流,一直是人类追求的一个梦想. 伴随着移动智能设备的普及,各家移动设备的厂家也开始在自家的设备 ...

  6. 基于Babylon.js编写宇宙飞船模拟程序1——程序基础结构、物理引擎使用、三维罗盘

    计划做一个宇宙飞船模拟程序,首先做一些技术准备. 可以访问https://ljzc002.github.io/test/Spacetest/HTML/PAGE/spacetestwp2.html查看测 ...

  7. Spring MVC-从零开始-@RequestMapping 注解method属性

    1.@RequestMapping 处理 HTTP 的各种方法(GET, PUT, POST, DELETE  PATCH) package com.jt; import org.springfram ...

  8. .Net Core与Vue.js模块化前后端分离快速开发解决方案(NetModular)

    NetModular是什么? NetModular不仅仅是一个框架,它也是一整套的模块化与前后端分离的快速开发的解决方案,目标是致力于开箱即用,让开发人员完全专注于业务开发,不需要关心底层封装和实现. ...

  9. ShutdownHook- Java 优雅停机解决方案

    想象一下,如果你现在刚好在 word 上写需求文档,电脑突然重启.等待开机完成,你可能会发现写了一个小时文档没有保存,就这么没了... 一个正在运行 Java 应用如果突然将其停止,影响不止数据丢失, ...

  10. ASP.NET Web API 2系列(一):初识Web API及手动搭建基本框架

    1.导言 随着Web技术的发展,现在各种框架,前端的,后端的,数不胜数.全栈工程师的压力越来越大. PC端,pad端,移动端App(安卓/IOS)的发展,使得前后端一体的开发模式十分笨重.因此,前后端 ...