Thymeleaf header 변수 추가

이로률·2023년 11월 1일

Thymeleaf

목록 보기
5/6
post-thumbnail

1. header.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <body>
    <header th:fragment="header(h1,p)">
		<div class="text-center text-white">
			<h1 class="display-4 fw-bolder" th:text="${h1}"></h1>
            <p class="lead fw-normal text-white-50 mb-0" th:text="${p}"></p>
		</div>
    </header>
    </body>
</html>

2. header 적용

다른 html에 header 적용 방법

<!-- Header-->
<header th:replace="layout/header::header(h1='Welcome', p='') "></header>

header 말고도 다른 레이아웃에 변수 추가하려면 이렇게 하면 되겠지 ?!?!

profile
💻🧐💗💝💘💖

0개의 댓글