th:text와 th:utext
th:text
텍스트를 출력하는데, 데이터 안에 있는 태그를 그대로 보여준다.
th:utext
텍스트를 출력하는데, 데이터 안에 있는 태그를 이용해서 보여준다.
컨트롤러에서 데이터를 보내보자
@GetMapping("/th-text")
public String thText(Model model) {
String text = "Hello<br>Spring";
model.addAttribute("text", text);
return "view/th-text";
}
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>th text</h2>
<div>
<p>
<span th:text="${text}"></span>
</p>
<p>
<span th:utext="${text}"></span>
</p>
</div>
</body>
</html>
화면 결과
'프로그래밍 > thymeleaf' 카테고리의 다른 글
타임리프(thymeleaf) 링크 URL 표현식 @{} (0) | 2021.09.28 |
---|---|
타임리프(thymeleaf) 선택 변수 표현식 *{} (0) | 2021.09.17 |
타임리프(thymeleaf) map 데이터 출력 (0) | 2021.09.15 |
타임리프(thymeleaf) th:each, 변수 표현식: ${...} (0) | 2021.09.04 |
타임리프(thymeleaf) (0) | 2021.09.03 |