1. Thymeleaf란?
: server-side java template engine
- JSP를 대체하는 템플릿 언어 및 엔진
- 모든 기능을 HTML element 의 속성으로 표현
2. JSP와 Thymeleaf 비교
3. Spring MVC Framework와의 연동
- Spring view resolution 방식에 따라 타임리프 템플릿을 뷰로 이용 가능하다.
- Form backing beans
- MessageSource 객체를 통해 Spring에서 관리되는 message file들에서 메시지 검색 및 출력
- SpEL 사용 가능
4. dependency 설정 (in Spring-Boot)
- auto-configuration
: 명시적인 bean 설정 필요없음
- Template file 기본 위치: src/main/resources/templates
5. Namespace 선언
6. 텍스트 출력
th:text 속성 : 주어진 식의 값을 tag의 content에 출력함(기존 값을 대체)
7. Standard Expression Syntax
8. 변수 식 : ${...}
사용 예)
9. 선택 변수 식 : *{...}
: 전체 context 대신 특정 객체에 대해 실행됨
1) th:object를 먼저 설정하고
2) *{...} 으로 뒤에 객체 선택
10. 메시지 식 : #{...}
11. Link URL : @{...}
: page, context, server, protocol에 대한 상대 경로 이용
12. Literals
13. Operations
14. 임의의 속성 설정(이미지)
15. 반복문 - th:each="..."
** 홀수번째만 속성을 적용하고 싶다면,
16. 조건문 ; th:if="...", th:unless="..."
17. Switch
18. Template layout
- id를 이용한 fragment 삽입
- 다양한 방식
- fragment는 params를 가질 수 있음
- th:remove
19. Form binding in Spring MVC
- checkbox
- radio button
- dropdown list
20. 검증 오류 메시지 출력
'Programming > Spring' 카테고리의 다른 글
09. Spring JDBC (0) | 2021.06.01 |
---|---|
08. MyBatis (0) | 2021.06.01 |
06. Spring Boot (0) | 2021.05.27 |
05. Spring MVC (0) | 2021.04.18 |
04. bean life-cycle관리 / 외부설정 property / message source (0) | 2021.04.13 |