依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.10</version>
</dependency>
在select语句之前,调用PageHelper.startPage(页码,每页行数)
@Override
public PageInfo<Student> queryLimit(int limit, int rows, String name) {
PageHelper.startPage(limit, rows);
List<Student> studentList = crudDao.queryLimit(name);
PageInfo<Student> pageInfo = new PageInfo<Student>(studentList);
return pageInfo;
}
输出信息:
{
"total": 80,
"list": [
{
"id": 5,
"name": "ssfasd",
"email": "fasdfa@qq.com",
"age": 18
},
{
"id": 6,
"name": "展示",
"email": "a@foxmail.com",
"age": 1
}
],
"pageNum": 3,
"pageSize": 2,
"size": 2,
"startRow": 5,
"endRow": 6,
"pages": 40,
"prePage": 2,
"nextPage": 4,
"isFirstPage": false,
"isLastPage": false,
"hasPreviousPage": true,
"hasNextPage": true,
"navigatePages": 8,
"navigatepageNums": [
1,
2,
3,
4,
5,
6,
7,
8
],
"navigateFirstPage": 1,
"navigateLastPage": 8
}
|