ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฐ˜์‘ํ˜•
SampleController.java
1
2
3
4
5
6
7
8
9
10
11
12
    @GetMapping("/sample3")
    public void sample3(Model model) {
        
        List<MemberVO> list = new ArrayList<>();
        
        for (int i = 0; i < 10; i++) {
            list.add(new MemberVO(i, "user0"+i, "userpw0"+i
                    , "๊น€ํ…Œ์ŠคํŠธ"+i, new Timestamp(System.currentTimeMillis())));
        }
        
        model.addAttribute("list", list);
    }
 

 

sample3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Thymeleaf3</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
</head>
 
<body>
 
    <!-- HTML ์ฃผ์„ -->
    <!--/* ํƒ€์ž„๋ฆฌํ”„ ์ฃผ์„ */-->
    <!-- /* th:with๋Š” ํ•ด๋‹น ์š”์†Œ์•ˆ์—์„œ ์‚ฌ์šฉํ•  ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•˜๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค. */ -->
    <!-- /*<c:set var="target" value="user03"/> */ -->
    <table border="1" th:with="target = 'user03'">
        <tr>
            <td>์•„์ด๋””</td>
            <td>์ด๋ฆ„</td>
            <td>๋“ฑ๋ก์ผ</td>
        </tr>
 
        <tr th:each="m : ${list}">
            <td>
                <p th:if="${m.memberId == target}">BLIND</p>
                <p th:if="${m.memberId != target}">[[${m.memberId}]]</p>
            </td>
            <td th:text="${m.memberName}"></td>
            <td>[[${m.regDate}]]</td>
        </tr>
    </table>
 
</body>
</html>
 
 

 

์‹คํ–‰ ๊ฒฐ๊ณผ

 

๋ฐ˜์‘ํ˜•
๋Œ“๊ธ€