gwooden_코린이

스프링 부트 타임리프 사용해보기 본문

스프링 부트

스프링 부트 타임리프 사용해보기

gwooden22 2023. 2. 14. 10:34
728x90

타임리프 - HTML을 동적화면으로 처리해주기 위한 라이브러리


<table>	
	<tr>
		<th>아이디</th>
		<th>제목</th>
		<th>작성일</th>
	</tr>
	<tr th:each="question, loop : ${questionList}">
		<td th:text="${question.id}"></td>
		<td th:text="${question.subject}"></td>
		<td th:text="${question.createDate}"></td>
		
		<td th:text="${loop.index}"></td>
		<!--count : 반복 횟수 | size : 개수 | first : 첫번째면 true 아니면 false | last : 마지막이면 true 아니면 false-->
		<!--odd : 반복 횟수가 짝수면 true 홀수면 false | even : 짝수면 false 홀수면 true-->
		
		<td th:switch="${question.id}">
			<spqn th:case="1">일</spqn>
			<spqn th:case="*">나머지</spqn>
		</td>
		
		<td th:if="${question.id == 1}" th:text="일이다"></td>
		<td th:unless="${question.id == 1}" th:text="일이아님"></td>
	</tr>
</table>
728x90
Comments