<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
</dependency>
//使用分頁插件對過濾後的資料進行分頁
Page page = new Page(pageNum, pageSize);
int total = resultList.size();
page.setTotal(total);
int startIndex = (pageNum-1) * pageSize;
int endIndex = Math.min(startIndex + pageSize,total);
page.addAll(resultList.subList(startIndex, endIndex));
PageInfo pageInfo = new PageInfo<>(page);
接下來可以将PageInfo做處理,放在自定義的分頁實體類中