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

教程分享 > Java教程 > Thymeleaf (1666) 2024-08-06 15:10:31

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 设置不校验html标签
Thymeleaf 递归,Thymeleaf模板引擎递归展示如评论留言等场合适用
使用thymeleaf 模板创建时间 使用thymeleaf 创建指定日期为:2023-10-18 #dates.create(2023,10,18) 使用thymeleaf ...
本文说一下在thymeleaf模板引擎中,如何给 textarea 赋值
springboot 使用thymeleaf 模板引擎中url中的&引起的org.xml.sax.SAXParseException: 对实体 "uid" 的引用必须以 ';' 分隔符结尾。问题解决
设置数据源将数据写入到 Model 中 @RequestMapping("/menulist") public String MenuManagerList(M
环境Thymeleaf 3.0循环5次需求:输出5个li编码参考:&lt;ul&gtl; &lt;li th:each="index:${#numbers.sequence(1,
配置在resources目录下面创建i18n目录,然后创建几个文件messages.properties 默认显示语言内容messages_en_US.prop