thymeleaf不能访问templat子集目录:template parsing (template: “class path resource [templates/test/test.html]

ps: 红色字体表示最新更正(错误真正的原因,以及最新解决办法)
其他的一个原因: 公共页面路径错误https://blog.csdn.net/qq_43987149/article/details/124337777

1、 问题描述

我把 jsp 转换为 HTML thymeleaf模板 版本时报错,其实这个错误不是转换问题,主要是 thymeleaf 对html相关文件存放路径的问题
最开始我存放的路径是在 templates 下面新建了一个文件夹,但是解析始终报错,最终我把html文件放到templates路径下(不放在fore下)启动运行成功。
在这里插入图片描述

2、 原因(maven错误,修改maven路径)

可能是thymeleaf 路径解析没有配置好,导致的解析错误,但是具体的先不管了,先根据thymeleaf模板默认方式处理。
错误原因是因为maven问题,我新建项目使用的maven是tomcat绑定的maven,导致模板解析有问题,所以一直报错

3、 解决办法

待解决
1、更改maven地址为自己本地安装的maven(如下图)
2、记得把setting.xml文件路径也修改为自己安装的maven setting.xml路径
3、 maven本地仓库也修改为setting.xml配置的路径(第二部修改好后,第三步可能默认修改)
4、 maven本地仓库更改参考: https://blog.csdn.net/qq_43987149/article/details/121052998
在这里插入图片描述

4、 所有相关错误

An error happened during template parsing (template: "class path resource [templates/test/test.html]")

Failed to complete request: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [common], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "fore/homePage" - line 3, col 7)

引用公共common页面时 with root cause TemplateInputException: Error resolving template [testcommon]

Caused by: org.attoparser.ParseException: Error resolving template [common], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "fore/homePage" - line 3, col 7)
	at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
	at org.attoparser.MarkupParser.parse(MarkupParser.java:257) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
	at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
	... 52 more
Caused by: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [common], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "fore/homePage" - line 3, col 7)
	at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
	at org.thymeleaf.engine.TemplateManager.parseStandalone(TemplateManager.java:250) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
	at org.thymeleaf.standard.expression.FragmentExpression.resolveExecutedFragmentExpression(FragmentExpression.java:588) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]



`event log: 16:10	EasyBuySpringBootApplication: Failed to retrieve application JMX service URL`

5、 其他

最开始我还以为这个错误是我引入thymeleaf common公共页面导致的错误,最后才发现是thymeleaf对HTML相关页面的解析路径问题。
真正的原因在第二点里面,是maven导致的错误

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值