pom.xml文件引入依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
application.yml进行配置
pagehelper:
helper-dialect: oracle // 没有默认值,必须指定该属性
reasonable:true
support-methods-arguments:true
代码使用
@GetMapping("/querryInfoOfPage")
public Result querryInfoOfPage(@RequestParam("startPage")int startPage,@RequestParam("size")int size) {
// 设置起始页startPage,每页显示条数size
PageHelper.startPage(startPage, size);
List <Info> infoList=queryService.queryAll();
PageInfo<Info> pageInfo =new PageInfo<>(infoList);
return ResultTemplate.getSuccessResult().withData(pageInfo);
}
常见坑
PageHelper.startPage(startPage, size);
List <Info> infoList=queryService.queryAll();
分页设置后面必须更查询,不然分页无效!!!