在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">«</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">»</span>
</a>
</li>
</ul>
</nav>
这样,翻页就可以使用了。