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导致的错误