sping-boot整合pageHelper

mybatis-plus分页使用

mybatis-plus分页使用

引入

<dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>5.1.2</version>
</dependency>

配置

#分页插件
pagehelper:
  helperDialect: mysql
  reasonable: true
  supportMethodsArguments: true
  params: count=countSql

简单使用

com.github.pagehelper.Page<Object> pageResult = PageHelper.startPage(page, size);
        List<AlarmStatisticVo> alarmStatisticVos = searchStatisticAlarm(alarmStatisticSearchRo);
        long total = pageResult.getTotal();
        PageHelper.clearPage();
        return new PageResult<>(alarmStatisticVos, total);
  List<Person> list = personService.getAllPerson();
        PageInfo<Person> pageInfo = new PageInfo<Person>(list);
        model.addAttribute("pageInfo",pageInfo);
        return "list";

其中:PageHelper.startPage(int PageNum,int PageSize):用来设置页面的位置和展示的数据条目数,我们设置每页展示5条数据。PageInfo用来封装页面信息,返回给前台界面。PageInfo中的一些我们需要用到的参数如下表:
PageInfo.list 结果集
PageInfo.pageNum 当前页码
PageInfo.pageSize 当前页面显示的数据条目
PageInfo.pages 总页数
PageInfo.total 数据的总条目数
PageInfo.prePage 上一页
PageInfo.nextPage 下一页
PageInfo.isFirstPage 是否为第一页
PageInfo.isLastPage 是否为最后一页
PageInfo.hasPreviousPage 是否有上一页
PageHelper.hasNextPage 是否有下一页

具体使用请看pageHelper的官方文档,此只为个人记录!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值