thymeleaf - block
This commit is contained in:
@@ -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));
|
||||||
|
|||||||
18
thymeleaf/src/main/resources/templates/basic/block.html
Normal file
18
thymeleaf/src/main/resources/templates/basic/block.html
Normal 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>
|
||||||
Reference in New Issue
Block a user