Thymeleaf - layout
th:replace 사용법
디렉토리 구조
src/main/resources/templates/common(여기서부터 만들어서 사용)
내가 알기 쉽게 또는 프로젝트 구조에 맞춰 패키지 생성해서 관리
보통 공용으로 사용하는 경우는 common 패키지로 관리
<html> 안에 th:fragment="변수명" 입력
<html th:fragment="HeaderFragment">
이제 적용시키고 싶은 경우
위 사진 같은 경우가 common 폴더 안에 넣은 공용으로 쓸 Header 부분
위 Header 부분을 아래 일정표에 th:replace해서 추가하려고 함
내가 만든 레이아웃 사용을 위해 <html> 안에
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
문구 삽입
이제 내가 만든 레이아웃을 사용하려는 영역에
<div 또는 각종 시멘틱 태그들 th:replace="경로:: 레이아웃변수명"></div> 입력후 사용