使用PageHelper进行分页查询
添加依赖:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.13</version>
</dependency>
使用方法:
PageHelper.startPage(collectionSearch.getPage(), collectionSearch.getSize());
List<DocumentContent> documentContentList = collectionIdentifyService.getArchiveIdsMultiCondition(collectionSearch, deptIds, user.getUserId());
PageInfo<DocumentContent> pageInfo = new PageInfo<>(documentContentList);
需要留意的是,紧挨PageHelper.startPage(collectionSearch.getPage(), collectionSearch.getSize());
的查询方法生效,如果在查询方法之后对返回数据进行处理,再PageInfo<DocumentContent> pageInfo = new PageInfo<>(documentContentList);
会造成pageInfo.getTotal()
等于pageInfo.getSize()
的情况。