thymeleaf - layout

This commit is contained in:
haerong22
2021-07-07 19:07:01 +09:00
parent 150bfb3720
commit 92bd837239
3 changed files with 33 additions and 0 deletions

View File

@@ -17,4 +17,9 @@ public class TemplateController {
public String layout() {
return "template/layout/layoutMain";
}
@GetMapping("/layoutExtend")
public String layoutExtends() {
return "template/layoutExtend/layoutExtendMain";
}
}

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html th:replace="~{template/layoutExtend/layoutFile :: layout(~{::title}, ~{::section})}"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>메인 페이지 타이틀</title>
</head>
<body>
<section>
<p>메인 페이지 컨텐츠</p>
<div>메인 페이지 포함 내용</div>
</section>
</body>
</html>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html th:fragment="layout (title, content)" xmlns:th="http://www.thymeleaf.org">
<head>
<title th:replace="${title}">레이아웃 타이틀</title>
</head>
<body>
<h1>레이아웃 H1</h1>
<div th:replace="${content}">
<p>레이아웃 컨텐츠</p>
</div>
<footer>
레이아웃 푸터
</footer>
</body>
</html>