
Thymeleaf 페이지 레이아웃 만들기전에 pom.xml 에 dependency 추가합니다.
pom.xml 에 추가하고나서 새로고침 실행합니다.

templates 밑에 fragments 폴더를 생성합니다. 그리고나서 footer.html, header.html 파일을 생성합니다.

fragments 폴더 밑에 하위 레이아웃 footer.html 를 작성합니다.


fragments 폴더 밑에 상위 레이아웃 header.html 를 작성합니다.

templates 폴더 밑에 thymeleafEx07.html 를 작성합니다.

templates 폴더 밑에 layouts 폴더를 생성합니다. layouts 폴더 밑에 layout1.html 를 작성합니다.
위와같이 클라이언트 화면을 작성하고 이제 서버쪽 Controller 에 코드를 작성하겠습니다.

Controller 패키지 ThymeleafExController.java

com.shop -> ShopApplication.java
크롬 url 에 @GetMapping으로 localhost:8080/ex07 입력합니다.

위와 같이 화면을 볼수 있습니다.
'BackEnd > SpringBoot' 카테고리의 다른 글
머스테치 (0) | 2022.04.24 |
---|---|
Spring Security (0) | 2022.04.13 |
Thymeleaf th:each (0) | 2022.04.12 |
Thymeleaf 사용법 (0) | 2022.04.12 |
Thymeleaf (0) | 2022.04.12 |