在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>

这样,翻页就可以使用了。


版权声明:本文为m0_37564426原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/m0_37564426/article/details/105746885