th:id, th:value, th:text

<input type="check" th:id="'check'+${info.seq}" th:value='${info.name}' th:text='${info.name}'></input>


th:classappend : 클래스 동적 추가

<div th:with="testClass = ${code == '01' ? : 'active' : ''}">
<li class="comm" th:classappend="${testClass}"> 코드가 01일때만 클래스 추가 </li>
</div>

`

not #strings.isEmpty( data ) : 문자열 null 체크, 빈값 체크


<th:block th:with="testText = ${not #strings.isEmpty(info.title) ? info.title : '입력해주'}">
</th:block>

`

th:selected : select박스 selected

<select name="selectPhone">
<option th:selected="${phone}=='010'">010</option>
<option th:selected="${phone}=='011'">011</option>
<option th:selected="${phone}=='012'">012</option>
</select>

`


th:each : 반복문

<!-- 받아온 데이터 langth만큼 loof -->
<div th:each="info,index : ${list}">
<input type="checkbox" th:id = "'check_' + ${index.index}">
<span th:text="${info.title}"></span>
</div>

<!-- 특정 지정숫자 만큼 loof -->
<div th:each="num : ${#number.sequence(1, 12)}">
<th:block th:with="month = ${num <= 9 ? '0'+num : num}">
<option th:value="${month}" th:text="${month}"></option>
</th:block>
</div>


th:if, th:unless

<div th:if="${data.type == '01'}">
타입이 01일때 태그 노출
</div>
<div th:unless="${data.type == '01'}">
타입이 01이 아닐때 태그 노출
</div>



th:switch case


<th:block th:switch="${type}">
<em th:case="01">01</em>
<em th:case="02">02</em>
<em th:case="*">그 외 (생략가능)</em>
</th:block>


th:with : 변수설정


<th:block th:with="titNm = ${data.tabType == '01' ? '첫번째탭' : '두번째탭'}
                 , outPutText = '텍스트'" >
<p th:text = "${titNm}"></p>
<p th:text = "${outPutText}"></p>
</th:block>

+ Recent posts