- 기본개념
- 사용방법
- 무조건 문자 리터럴은 작은 따옴표로 감싸야 함
<span th:text="'hello'">
- 단, 공백 없이 쭉 이어질 경우에는 하나의 의미있는 토큰으로 인지하므로 작은 따옴표 생략 가능
- 룰: A-Z , a-z , 0-9 , [] , . , - , _
<span th:text="hello">
- 적용예시
@GetMapping("/literal")
public String literal(Model model) {
model.addAttribute("data", "Spring!");
return "basic/literal";
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>리터럴</h1>
<ul>
<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>
</ul>
</body>
</html>