본문 바로가기

thymeleaf

타임리프 리터럴 대체

#오류 - 타임리프 문자 리터럴은 '     ' 로 감싸져야함(다만 공백이 없으면 용인해줌ㅋ)

<span th:text="hello world!"></span>

#아래와 같이 디버깅 - 공백이 있는 문자 리터럴을 '   '로 감쌌다

<span th:text="'hello world!'"></span>

 

#model.data == 'world!'일 때,

<li>'hello' + ' world!' = <span th:text="'hello' + ' world!'"></span></li>
<li>'hello world!' = <span th:text="'hello world!'"></span></li>
<li>'hello ' + ${data} = <span th:text="'hello ' + ${data}"></span></li>
<li>리터럴 대체 |hello ${data}| = <span th:text="|hello ${data}|"></span></li>

 

 

★★★문자 리터럴 편하게 사용하기

<span th:text="'hello ' + ${data}"></span> #불편

<span th:text="|hello ${data}|"></span> #편안

'thymeleaf' 카테고리의 다른 글

타임리프 div 여러개 묶어서 반복  (0) 2022.06.27
타임리프 조건문  (0) 2022.06.27
타임리프 반복문  (0) 2022.06.27
타임리프 데이터 없을 때  (0) 2022.06.27
타임리프 href  (0) 2022.06.27