프레임워크/Thymeleaf
Thymeleaf(타임리프) 기본문법 - 표현식
최승호
2022. 5. 20. 12:00
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#standard-expression-syntax
Tutorial: Using Thymeleaf
1 Introducing Thymeleaf 1.1 What is Thymeleaf? Thymeleaf is a modern server-side Java template engine for both web and standalone environments, capable of processing HTML, XML, JavaScript, CSS and even plain text. The main goal of Thymeleaf is to provide a
www.thymeleaf.org
타임리프는 HTML에서 다양한 유형의 데이터를 표현할 수 있는 표현식(Expression)이 있으며 다음은 표준 표현식에 대한 간단한 요약이다.
표준 표현식
간단 표현식
- 변수 표현식 : ${...}
- 선택 변수 표현식 : *{...}
- 메시지 표현식 : #{...}
- 링크 URL 표현식 : ${...}
- 공통조각 표현식 : !{...}
리터럴
- 문자 리터럴 : 'one text', 'Another one!', ...
- 숫자 리터럴 : 0, 34, 3,0, 12,3, ...
- 논리 리터럴 : true, false
- Null 리터럴 : null
- 리터럴 토큰 : one, sometext, main, ...
문자 연산
- 문자열 합치기 : +
- 리터럴 대체 : |The name is ${name}|
숫자 연산
- 이진연산 : +, -, *, /, %
- 단항연산 : -
논리 연산
- 이진연산 : and, or
- 단항연산 : !, not
비교 연산
- 크기비교 : >, <, >=, <= (gt, lt, ge, le)
- 동등비교 : ==, != (eq, ne)
조건 연산
- if-then : (if) ? (then)
- if-then-else : (if) ? (then) : (else)
- Default : (value) ?: (defaultValue)
특수 토큰
- 연산하지 않음 : _