기존(310)/🏀Thymeleaf
[thymeleaf] th:utext (이스케이프) 사용
조각남자
2022. 11. 7. 21:18


1. basic - text-unescaped.html 을 만든다
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"> <!--이거 작성해야 타임리프 사용가능..-->
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>컨텐츠에 데이터 출력하기</h1>
<ul>
<li>th:text 사용 <span th:text="${data}"></span></li>
<li>th:utext 사용 <span th:utext="${data}"></span></li>
</ul>
<ul>
<li><span th:inline="none">[[...]] = </span>[[${data}]]</li>
<li><span th:inline="none">[(...)] = </span>[(${data})]</li>
</ul>
</body>
</html>
2.Controller 가기
@GetMapping("/text-unescaped")
public String unescaped(Model model){
model.addAttribute("data","Hello <b>Spring</b>");
return "basic/text-unescaped";
}
3.localhost:8080/basic/text-unescaped 열어보기
