728x90
반응형
SMALL
...
<tr th:each="question, loop : ${paging}">
			<td th:text="${paging.getTotalElements - (paging.number * paging.size) - loop.index}"></td>
			<td>
				<a th:href="@{|/question/detail/${question.id}|}"
				th:text="${question.subject}"></a>
			</td>
			<td th:text="${#temporals.format(question.createDate, 'yyyy-MM-dd HH:mm')}"></td>
</tr>
...

현재 질문 목록을 보면 어느 페이지든 모두 번호가 1부터 시작한다.

각 게시물에 맞는 번호가 표시되도록 하자.

 

게시물 번호 공식 만들기

게시물 번호 = 전체 게시물 개수 - ( 현재 페이지 * 페이지당 게시물 개수 ) - 나열 인덱스

 

게시물 번호 공식 적용하기

/templates/question_index.html

<tr th:each="question, loop : ${paging}">
			<td th:text="${paging.getTotalElements - (paging.number * paging.size) - loop.index}"></td>
			<td>
				<a th:href="@{|/question/detail/${question.id}|}"
				th:text="${question.subject}"></a>
			</td>
			<td th:text="${#temporals.format(question.createDate, 'yyyy-MM-dd HH:mm')}"></td>
		</tr>

역으로 나오는 것을 확인

728x90
반응형
LIST

+ Recent posts