-
[thymeleaf] 타임리프Front 2019. 12. 16. 23:36
템플릿엔진
<html lang="en" xmlns:th="http://www.thymeleaf.org">
${..?} null체크. 값이 null이면 빈값이 출력된다 ${board?.idx}
@{...} - 링크표현 @{/oreder/details(id=1, action='show_all')} <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" />
#temporals - 날짜 포맷팅 함수 .arrayFormat(...) Array 타입 -> 날짜값 .listFormat(...) .setFormat(...) <tr th:each="board : ${boardList}"> <td th:text="${board.idx}"></td> <td th:text="${board.boardType.value}"></td> <td><a th:href="'/board?idx='+${board.idx}" th:text="${board.title}"></a></td> <td th:text="${board.createdDate} ? ${#temporals.format(board.createdDate,'yyyy-MM-dd HH:mm')} : ${board.createdDate}"></td> </tr>
th:href
th:src
th:text
th:style
th:class
th:fragment - 레이아웃 이름지정
th:insert = "경로:: fragment이름"
th:replace ="경로::
th:include
th:if - 화면에 띄울 조건
th:each - 순차접근
th:with - 변수정의 // th:with="startNumber=${...}, endNumber= ${...}"
#numbers.sequece(시작변수,끝변수)
** 둘은 같은 결과
<input type="text" th:field="*{datePlanted}" />
<input type="text" id="datePlanted" name="datePlanted" th:value="*{datePlanted}" />