java - SpringBoot Thymeleaf 无法解析模板

标签 java maven intellij-idea spring-boot

我使用 SpringBoot 1.3.3.RELEASE 和 Thymeleaf 以及 IntelliJ 作为我的 IDE。我收到此错误:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "footer.html", template might not exist or might not be accessible by any of the configured Template Resolvers (about:102)

我有这个项目布局: enter image description here

我在 about.html 文件上使用此导入:

<div th:replace="footer.html"></div>

我无法通过 IntelliJ 或 SpringBoot Maven 插件让它工作。我正在使用嵌入式 Tomcat 来运行这个项目。我尝试将片段放入模板下的片段文件夹中,还有这个

<div th:fragment="footer.html"></div>

如有任何帮助,我们将不胜感激。

最佳答案

您的 footer.html 是什么样子的? 如果你想使用片段,你必须这样做:

<div th:replace="footer :: fragmentName"></div>

在 footer.html 中你会有类似的内容

<div th:fragment="fragmentName">Hello World</div>

关于java - SpringBoot Thymeleaf 无法解析模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36286477/

相关文章:

java - 所有可能的对

java - 将文件添加到java中的file[]语句中

java - 字符串和文字有什么区别?

java - 在maven中将文件从一个项目复制到另一个项目

android - 我可以使用 Android Studio 为 Android Studio 制作插件吗?

java - Spring Boot 缓存 TTL

java - maven 添加 zip 文件以部署到远程服务器

maven - 从远程存储库安装 JAR (clojar)

intellij-idea - 如何在IntelliJ IDEA中更改Markdown预览字体大小?

java - 从 IntelliJ Idea Community 运行嵌入式 Tomcat 时遇到问题