没有找到 html 模板,Spring Boot and Thymeleaf:找不到HTML模板
我正在嘗試用Thymeleaf創建一個基於Spring Boot的應用程序。我使用PetClinic樣本作爲起點。 我的應用程序找不到一些模板。Spring Boot and Thymeleaf:找不到HTML模板
我的項目是建立在標準的方式:
/src
/main
/java
/com.example
MyWebApplication.java
HomeController.java
/resources
/static
/css
/templates
/fragments
layout.html
home.html
application.properties
的pom.xml
org.springframework.boot
spring-boot-starter-parent
1.5.1.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter-thymeleaf
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-devtools
true
MyWebApplication.java
@SpringBootApplication
public class MyWebApplication {
public static void main(String[] args) {
SpringApplication.run(MyWebApplication.class, args);
}
}
HomeController.java
home.html做爲
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
th:replace="~{fragments/layout :: layout (~{::body},'home')}">
Welcome
的layout.html
th:fragment="layout (template, menu)">
Web InterfaceToggle navigation
application.properties是空的。
當我瀏覽到http://localhost:8080我得到的錯誤:
Error resolving template "~{fragments/layout", template might not exist or might not be accessible by any of the configured Template Resolvers (home:5)
如果我刪除了「日:更換」從home.html的屬性,它會顯示歡迎信息。
瀏覽類似問題(例如this one),我看到其他人創建了ThymeleafViewResolver bean。
問題:
爲什麼不能找到我的模板?
我是否需要創建模板解析器?如果是這樣,那麼寵物診所樣本怎麼沒有?它的模板解析器來自哪裏?
據我所見,它的設置方式與寵物診所樣品一樣,那麼有什麼區別?
2017-02-03
AlanW
總結
以上是生活随笔為你收集整理的没有找到 html 模板,Spring Boot and Thymeleaf:找不到HTML模板的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 计算机专业i7 7500u,8550U比
- 下一篇: web项目html页面过多,详解webp
