내용

글번호 1182
작성자 허진경 (나자바바)
작성일 2023-01-13 17:48:28
제목 타임리프 치트키
내용 1. 모든 html 파일은 다음처럼 네임스페이스를 설정해야 합니다. <html xmlns:th="http://www.thymeleaf.org"> 2. 국제화 메시지 출력은 #{ }를 사용합니다.(국제화 설정파일이 있어야 합니다.) <p>[[#{home.message}></p> <p th:text="#{home.message}">message</p> 3. request 데이터의 출력은 ${ }를 사용합니다. <p>[[${message}></p> or <p th:text="${message}">message</p> 세션 scope는 session객체를 사용합니다.(예: <p th:text="${session.message}">message</p>) 4. URL은 @{ }를 사용합니다. <a th:href="@{/favicon.png}"> <a th:href="@{/board/{id}/{page}(id=${board.boardId}, page=${session.page})}"> <img th:src="@{/file/{id}(id=${board.fileId})}"> or <img th:src="@{/file/__${board.fileId}__}"> 5. 반복 처리는 each속성을 사용합니다. <tr th:each="board : ${boardList}"> <td>[[${board.boardId}></td> <td th:text="${board.boardId}">boardId</td> 반복 처리 시 인덱스를 사용하려면 #numbers.sequence() 함수를 사용합니다. <p th:each="num: ${#numbers.sequence(1, board.replyStep)}"> 6. 조건 처리는 if를 사용합니다. <p th:if="${email==null}"> <span th:if="${board.replyNumber>0}"> 7. 입력 양식의 속성들의 예입니다. <input type="button" th:value="#{SIGN_IN}"> <input type="text" name="passwprd" th:placeholder="#{MEMBER_PW}"> 8. 조건에 따라 속성 추가는 다음처럼 합니다. <p th:classappend="${email!=null}?has-email}"> <option th:attrappend="data-path=${email!=null}?@{/account/__${user}__}"> <option th:value="${userEmail}" th:selected="${user.gender eq 'F'}"> 9. 날짜 형식은 #dates.format() 함수를 사용하고 숫자 형식은 #numbers.formatDecimal() 함수를 사용할 수 있습니다. <p th:text="${#dates.format(board.writeDate, 'YYYY-MM-dd')}"> <p th:text="${#numbers.formatDecimal(board.fileSize,3,'COMMA',2,'POINT')}"> 10. 외부 파일을 include 하려면 include 되는 파일의 엘리먼트에는 다음과 같이 fragment 속성이 있어야 하며. <head th:fragment="header"> include 하는 곳에는 다음과 같이 replace 속성이 있어야 합니다. <head th:replace="~{include/header :: header}"></head>
첨부파일 타임리프치트키.txt (2,222byte)