解决使用Thyemleaf Error resolving template "/sc/getView", template might not exist or might 问题

如果使用 Thyemleaf 模板中 <header></header>标签来引进公共的html  需要注意

<header id="header" th:replace="top::html"></header>

th:replace里面不可以开头加   /    开发工具中运行没问题,如果打成Jar包则会解析不出来

一个小坑,记录一下,有不对的地方,希望大家指点出来

 

引用\[1\]:解决:org.thymeleaf.exceptions.TemplateInputException: Error resolving template \[index\], template might not exist or might not be accessible by any of the configured Template Resolvers 。 引用\[2\]:这么多错误信息,我们只要关注这句话:Error resolving template \[auth/login\], template might not exist or might not be accessible by any of the configured Template Resolvers,这句话是什么意思呢? 引用\[3\]:一、问题Error resolving template \[/index\], template might not exist or might not be accessible by any of the configured Template Resolvers出现在 SpringBoot 项目使用 java -jar 运行时 二、解决 分别检查下面三个地方 2.1 在 pom.xml 中添加 thymeleaf 依赖 没有的话加下,有的话不用加 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> 2.2 application.yml添加相应的thymeleaf 的配置 我原先的配置不全,是错误的需要修改成下面这样 thymeleaf: prefix: classpath:/templates/ #prefix:指定模板所在的目录 check-template-location: true #check-tempate-location: 检查模板路径是否存在 cache: false #cache: 是否缓存,开发模式下设置为false,避免改了模板还要重启服务器,线上设置为true,可以提高性能。 suffix: .html #encoding: UTF-8 #content-type: text/html mode: HTML5 示例图(方便大家对应着看) 。 问题:Error resolving template \[grade/list\], template might not exist or might not be accessible by any of the configured Template Resolvers 回答: 这个错误信息是关于模板解析的问题。它表示模板解析器无法找到或访问指定的模板。\[1\]具体来说,它可能是因为模板不存在或者无法被配置的模板解析器访问到。\[2\]解决这个问题的方法有几个步骤。首先,检查项目的pom.xml文件中是否添加了thymeleaf依赖,如果没有则需要添加。\[3\]其次,检查application.yml文件中的thymeleaf配置是否正确,包括指定模板所在的目录、检查模板路径是否存在、是否缓存等。最后,确保模板文件存在于指定的目录中,并且文件名和路径与代码中的引用一致。这样就可以解决模板解析的问题了。 #### 引用[.reference_title] - *1* [Error resolving template [index], template might not exist or might not be accessible by any of the](https://blog.csdn.net/weixin_45790889/article/details/127026694)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [解决Error resolving template [x] template might not exist or might not be accessible by any of the ...](https://blog.csdn.net/lvoelife/article/details/126450694)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Error resolving template [], template might not exist or might not be accessible by any of the conf](https://blog.csdn.net/qq_43377749/article/details/115468087)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值