第一步:
导入MAVEN依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.12</version>
</dependency>
第二步:
yml配置文件新增以下配置
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
第三步:代码中使用
PageHelper.startPage(getPageNum(),getPageSize());//手动开启分页
List<GameLtv> gameLtvs = gameLtvMapper.selectGameLtvList(param);//执行查询
PageInfo<GameLtv> pageInfo = new PageInfo<GameLtv>(gameLtvs);//获取分页情况
int total = pageInfo.getTotal();//获取分页数据-总记录数
补充1.Mapper的写法 (正常写,没有什么需要特殊注意的)
补充2.请求参数实体的写法(字段名尽量用 pageNum 和 pageSize )
补充3.Mapper.xml (正常写,没有什么需要特殊注意的)