<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        select {
            width: 80px;
            height: 100px;
        }
    </style>
</head>
<body>

<h1 th:text="|year : ${year}|"></h1> <!-- request 객체에 저장한 데이터 사용할 때 -->
<h1 th:text="|id : ${session.id}|"></h1> <!-- session 객체에 저장된 데이터 사용할 때-->
<h1 th:text="|email : ${application.email}|"></h1> <!-- application 객체에 저장된 데이터 사용할 때-->
<a href="board.html" th:href="@{/board/list(bno=${bno}, type='L')}">abcabc</a> <!-- url의 쿼리스트링을 만들어줌. -->

<!-- 반복문 사용하기. list에서 하나씩 꺼내서 opt에 담는다-->
<select name="" id="" multiple>
    <option th:each="opt : ${list}" th:value="${opt}">[[${opt}]]</option> 
</select>

<!-- 블럭 단위로 반복문을 사용하고 싶을 때-->
<th:block th:each="opt : ${list}"> 
    <input type="checkbox" th:value="${opt}">[[${opt}]]<br>
</th:block>


<table border="1px">
    <tr th:each="item : ${list}">
        <td th:text="${item}"></td>
    </tr>
    <!-- not if 문. -->
    <tr th:unless="${list.size}==0">
        <td>게시물이 없습니다.</td>
    </tr>
</table>
    <h1 th:text="${lastName}">lastName</h1>
    <h1>[[${firstName}]]</h1>
    <span th:text="${'<i>Yoonki, Kim</i>'}"></span> <!-- 태그를 인식 시키지 않고 텍스트 그대로 나타내고 싶을 때-->
    <span th:utext="${'<i>Yoonki, Kim</i>'}"></span> <!-- 태그를 인식시키고 싶을 때-->

    <h1 th:text="|My name is ${lastName}, ${firstName}|"></h1> <!-- 문자열 안에 변수 사용하고 싶을 때-->

<!-- 자바스크립트에서 값을 사용할 때 쌍따옴표안에 담아준다-->
<!-- let firstName = "Kim" -->
<script th:inline="javascript">
    let firstName = [[${firstName}]]
    let lastName = [[${lastName}]]
    let arr = [[${list}]]
    let userObj = [[${user}]]

</script>
</body>
</html>

 

+ Recent posts