${...} : Variable expressions - OGNL 표현식, 스프링환경에서는 Spring EL
${shop.product.name} <span th:text="${session.user.name}">
*{...} : Selection expressions - 변수 표현식과 동일하지만, 전체 컨텍스트 맵이 아닌 이전에 선택한 객체가 기준이됨
*{product.name} <div th:object="${product}"> ... <span th:text="*{name}">...</span> ... </div>
#{...} : Message (i18n) expressions - .properties 같은 파일에서 값을 읽어 표현 할 수 있다. Spring 환경에서는 MessageSource과 통합됨 (docs.spring.io/spring-framework/docs/4.3.30.RELEASE/spring-framework-reference/htmlsingle/#context-functionality-messagesource)
#{homepage.title} <div> ... <span th:text="#{homepage.title}">...</span> ... <span th:text="#{homepage.desc}">...</span> ... </div>
@{...} : Link (URL) expressions
<a th:href="@{/order/list}">...</a>
/myapp 컨텍스트에서 실행되고있는 어플리케이션은 실행되면 다음과 같이 변경된다.
<a href="/myapp/order/list">...</a>
프로토콜 생략 - 절대주소와 비슷하지만 브라우저와 동일한 http, https 프로토콜을 사용함
<a th:href="@{//static.mycompany.com/res/initial}">...</a> // 제대로 표현 <a th:href="@{http://www.mycompany.com/main}">...</a>
~{...}: Fragment expressions - 마크업 템플릿을 표현하고, 쉽게 배치할때 사용할 수 있음
<!-- header.html --> <div th:fragment="title"> hello world </div> <!-- document.html --> ... <!-- 템플릿 부분(fragment)참조 --> <div th:insert="~{header :: title}"></div> ... <!-- 템플릿 전체 참조 --> <div th:insert="~{header}"><div>
참고
www.thymeleaf.org/doc/articles/standarddialect5minutes.html
'Spring' 카테고리의 다른 글
@EnableScheduling 설정하지 않았는데 Schedule 동작 시 (0) | 2024.01.17 |
---|---|
Querydsl Tech Talk 정리 (0) | 2021.08.10 |
SpringBoot Mysql Datasource 세팅 (0) | 2020.11.16 |
Spring Cloud Gateway - API Gateway 맛보기 (5) | 2020.10.19 |
Spring Security OAuth2 - Authorization endpoint (0) | 2020.10.07 |