自定义一个分页类
total为总记录数, result为当前分页的结果
public class PageResult <T>{
private Long total;
private List<T> result;
在mybatis配置文件中加入分页插件
<!-- 分页插件 -->
<plugins>
<!-- com.github.pagehelper 为 PageHelper 类所在包名 -->
<plugin interceptor="com.github.pagehelper.PageHelper">
<!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL 六种数据库-->
<property name="dialect" value="mysql"/>
</plugin>
</plugins>
service层加以下逻辑
页面
工程代码
链接: https://pan.baidu.com/s/1OKAJ6ftuphcLo3zSEcjgwA 提取码: 99ps