2017-05-09 81 views
0

我使用Sping引導(1.5.3.RELEASE),百里香和百里香佈局方言。我有一個片段名爲breadcrumb.html(/模板/片段):將百里香片段插入百里香佈局

<!DOCTYPE html> 
 
<html xmlns:th="http://www.thymeleaf.org"> 
 
<ul th:fragment="breadcrumb" th:each="link : ${session.currentBreadCrumb}"> 
 
\t <li th:text="${link.label}"></li> 
 
</ul> 
 
</html>

而且我有佈局的layout.html(/模板/佈局)


 

 
    <!DOCTYPE html> 
 
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"> 
 
<head> 
 
<title>Layout page</title> 
 
</head> 
 
<body> 
 
\t <header> 
 
\t \t <h1>My website</h1> 
 
\t </header> 
 
\t <div layout:include="../fragments/breadcrumb :: breadcrumb"></div> 
 
\t 
 
\t <section layout:fragment="content"> 
 
\t \t <p>Page content goes here</p> 
 
\t </section> 
 
\t <footer> 
 
\t \t <p>My footer</p> 
 
\t \t <p layout:fragment="custom-footer">Custom footer here</p> 
 
\t </footer> 
 
</body> 
 
</html>

我有一個home.html(/模板)

<!DOCTYPE html> 
 
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layouts/layout"> 
 
<head> 
 
<title>Home</title> 
 
</head> 
 
<body> 
 

 
</body> 
 
</html>

是我想要做的實現?我錯過了一些愚蠢的東西嗎?

親切的問候, 戴夫

+0

您尚未在home.html中定義佈局:fragment =「content」 – SAP

回答