经过学习总结出的-----使用page手动对list进行分页的方法:
数据装入list之后
Page page = new Page(pageable.getPageNumber()+1,pageable.getPageSize());
// 获取list的大小
int total = list.size();
page.setTotal(total);
int startIndex = pageable.getPageNumber() * pageable.getPageSize();
int endIndex = Math.min(startIndex+pageable.getPageSize(),total);
page.addAll(list.subList(startIndex,endIndex));
// objectPageInfo就是分好页的对象
PageInfo<Object> objectPageInfo = new PageInfo<>(page);
其中pageable是Pageable的实例化对象,分页完成,效果:
"pageNum": 1,
"pageSize": 20,
"size": 8,
"startRow": 1,
"endRow": 8,
"total": 8,
"pages": 1,
"list": [
{
{},
{},
.....
],
"prePage": 0,
"nextPage": 0,
"isFirstPage": true,
"isLastPage": true,
"hasPreviousPage": false,
"hasNextPage": false,
"navigatePages": 8,
"navigatepageNums": [
1
],
"navigateFirstPage": 1,
"navigateLastPage": 1,
"firstPage": 1,
"lastPage": 1
结束