Jin's Dev Story

[SpringBoot] 페이징 처리 본문

Web & Android/SpringBoot

[SpringBoot] 페이징 처리

woojin._. 2023. 10. 14. 10:01

부트스트랩 사용 시 해당 코드 재사용 가능

<!-- 부트 스트랩 사용할 때 재사용 가능 -->
            <div th:with="start=${(items.number/maxPage)*maxPage + 1}, end=(${(items.totalPages == 0) ? 1 : (start + (maxPage - 1) < items.totalPages ? start + (maxPage - 1) : items.totalPages)})" >
                  <ul class="pagination justify-content-center">

                        <li class="page-item" th:classappend="${items.first}?'disabled'">
                              <a th:onclick="'javascript:page(' + ${items.number - 1} + ')'" aria-label='Previous' class="page-link">
                                    <span aria-hidden='true'>Previous</span>
                              </a>
                        </li>

                        <li class="page-item" th:each="page: ${#numbers.sequence(start, end)}" th:classappend="${items.number eq page-1}?'active':''">
                              <a th:onclick="'javascript:page(' + ${page - 1} + ')'" th:inline="text" class="page-link">[[${page}]]</a>
                        </li>

                        <li class="page-item" th:classappend="${items.last}?'disabled'">
                              <a th:onclick="'javascript:page(' + ${items.number + 1} + ')'" aria-label='Next' class="page-link">
                                    <span aria-hidden='true'>Next</span>
                              </a>
                        </li>
                  </ul>
            </div>

 

'Web & Android > SpringBoot' 카테고리의 다른 글

[SpringBoot] 에러 처리  (0) 2023.10.14
[SpringBoot] @Annotation  (1) 2023.10.14
[SpringBoot] ResponseEntity  (0) 2023.10.14
[SpringBoot] Entity  (0) 2023.10.14
[SpringBoot] enum Class (열거형)  (0) 2023.10.14