본문 바로가기

프로그래밍/String boot

thymeleaf를 쓸 때 layout dialect 이용하기

 

스프링 부트로 새 프로젝트를 만들면서 타임 리프를 이용하게 되었다.

기존 스프링에서는 레이아웃 관리하는 용도로 타일즈를 이용했었는데 타임리프는 어떤 것이 있나 찾아보다가 layout dialect 라는 것이 있다는 것을 알았다.

 

먼저 프로젝트의 pom.xml에 타임리프 메이븐을 추가하고(기존에 있었다.)

layout dialect 메이븐을 추가한다. 

https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect/2.3.0

 

Maven Repository: nz.net.ultraq.thymeleaf » thymeleaf-layout-dialect » 2.3.0

A dialect for Thymeleaf that allows you to use layout/decorator templates to style your content. Note: There is a new version for this artifact nz.net.ultraq.thymeleaf thymeleaf-layout-dialect 2.3.0 // https://mvnrepository.com/artifact/nz.net.ultraq.thyme

mvnrepository.com

여기에서는 버전이 나올텐데 spring-boot-start-parent 가 버전을 관리해주기 때문에 버전은 지운다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
        <dependency>
            <groupId>nz.net.ultraq.thymeleaf</groupId>
            <artifactId>thymeleaf-layout-dialect</artifactId>
        </dependency>
cs