gpt4 book ai didi

java - 无法在我的 Springboot 应用程序中检索模板

转载 作者:行者123 更新时间:2023-11-28 21:57:49 24 4
gpt4 key购买 nike

我的索引文件的主体如下所示:

<div class="container" style="width: 100% !important;">

<!--Header-->
<div th:replace="fragments/header :: header"></div>

<!--Content-->
<!--<div th:replace="@{'fragments/' + ${template}} :: ${template}"></div>-->

<!--Footer-->
<div th:replace="fragments/footer :: footer"></div>

</div>

它似乎在提示我的页眉评论下的行,但我不确定为什么。可能发生了什么?

这是我的错误:

Mon Feb 06 16:06:26 CET 2017
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving fragment: "~{'fragments/header' :: header}": template or fragment could not be resolved (template: "index" - line 34, col 10)

异常(exception):

org.thymeleaf.exceptions.TemplateInputException: Error resolving fragment: "~{'fragments/header' :: header}": template or fragment could not be resolved (template: "index" - line 34, col 10)
at org.thymeleaf.standard.expression.FragmentExpression.resolveExecutedFragmentExpression(FragmentExpression.java:593) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.computeFragment(AbstractStandardFragmentInsertionTagProcessor.java:368) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.doProcess(AbstractStandardFragmentInsertionTagProcessor.java:111) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.engine.TemplateModel.process(TemplateModel.java:136) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:593) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.3.RELEASE.jar:3.0.3.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:337) ~[thymeleaf-spring5-3.0.3.M1.jar:3.0.3.M1]
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:186) ~[thymeleaf-spring5-3.0.3.M1.jar:3.0.3.M1]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1271) ~[spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) ~[spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) ~[spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:964) ~[spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:856) ~[spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:841) ~[spring-webmvc-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at

最佳答案

是否有一个带有

的文件 templates/fragments/header.html
< ... th:fragment="header">

在类路径中?

关于java - 无法在我的 Springboot 应用程序中检索模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42070998/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com