thymeleaf - block

This commit is contained in:
haerong22
2021-07-06 21:16:55 +09:00
parent 97884965f4
commit 5ae2c9df13
2 changed files with 25 additions and 0 deletions

View File

@@ -108,6 +108,13 @@ public class BasicController {
return "basic/comments"; return "basic/comments";
} }
@GetMapping("/block")
public String block(Model model) {
addUsers(model);
return "basic/block";
}
private void addUsers(Model model) { private void addUsers(Model model) {
List<User> list = new ArrayList<>(); List<User> list = new ArrayList<>();
list.add(new User("userA", 10)); list.add(new User("userA", 10));

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<th:block th:each="user : ${users}">
<div>
사용자 이름1 <span th:text="${user.username}"></span>
사용자 나이1 <span th:text="${user.age}"></span>
</div>
<div>
요약 <span th:text="${user.username} + ' / ' + ${user.age}"></span>
</div>
</th:block>
</body>
</html>