springboot:實現分頁查詢,以及翻頁功能

在pom.xml中引入依賴

<!-- 分頁查詢插件 -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.12</version>
        </dependency>

controller層

service層

 

映射配置xml文件

 

訪問

 

 

 

 翻頁功能: 翻頁需要使用到PageInfo對象

 html如下:

<nav aria-label="Page navigation">
    <ul class="pagination">

        <li th:class="${pageInfo.prePage} == 0 ? 'disabled':'' ">
            <!-- 上一頁-->
            <a th:href="${pageInfo.prePage} == 0 ? 'javascript:void(0)':@{'/account/list?pageNum='+${pageInfo.prePage}}" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>

        <li  th:each="pageNum : ${pageInfo.navigatepageNums}"><a th:href="@{'/account/list?pageNum='+${pageNum}}">[[${pageNum}]]</a></li>

        <li  th:class="${pageInfo.nextPage} == 0 ? 'disabled':'' ">
            <a th:href="${pageInfo.nextPage} == 0 ? 'javascript:void(0)':@{'/account/list?pageNum='+${pageInfo.nextPage}}" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
    </ul>
</nav>

這樣,翻頁就可以使用了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章