thymeleaf报错找不到模板文件template might not exist or

位置:首页>文章>详情   分类: 教程分享 > Java教程   阅读(1141)   2023-03-28 11:29:14

thymeleaf模板 报错信息:

错误信息
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/admin/adminLayout], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "admin/pages/dashboard" - line 5, col 7)

错误发生情况,开发环境是好好的没问题。打包发布就报错了。究其原因是因为路径问题。

默认的 thymeleaf template 路径前缀是 classpath:/template/

这里由于我的layout路径配置的是  /admin/adminLayout 两个拼接就变成了

classpath:/template//admin/adminLayout  

导致了路径多了一个/


解决办法就是去掉引入时候的最前面的/,改为
<html lang="zh"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorate="~{admin/adminLayout}">

提示:同样的问题也可能发生在controller里面的return 路径


至于开发为啥没报错估计是Windows下面自动处理了?

搞定收工。
 
地址:https://www.leftso.com/article/1098.html

相关阅读

thymeleaf模板 报错信息:​​​​​​​org.thymeleaf.exceptions.TemplateInputException: Error resolving template...
SSH/SSM项目中如何集成thymeleaf?本文将讲解SSH/SSM项目中如何集成thymeleaf模板引擎
Thymeleaf 递归,Thymeleaf模板引擎递归展示如评论留言等场合适用
本文说一下在thymeleaf模板引擎中,如何给 textarea 赋值
thymeleaf 设置不校验html标签
springboot 使用thymeleaf 模板引擎中url中的&引起的org.xml.sax.SAXParseException: 对实体 "uid" 的引用必须以 ';' 分隔符结尾。问题解决
升级环境说明目前项目使用的2.3.7版本(自己感觉还行,但是官方已经停止支持了。)Spring Boot 官方支持情况spring boot 官方支持情况官方在今年8月就终止了对2.3.x的版本...
一、项目环境Spring Boot 2.1.2.RELEASEshiro-spring 1.4二、去掉URL jsessionid在shiro配置中,配置关闭url中显示sessionId ...
spring boot 开发技巧,在开发web项目中跳过thyemeleaf模板/js/css等缓存避免每次修改资源文件都需要重启服务器