Page<PersonalReport> reportPage = new Page<>();
reportPage.setTotal(personalReportList.size());
//对结果进行分页操作
if (CollectionUtil.isNotEmpty(personalReportList)) {
int fromIndex = (page.getCurrent() - 1) * page.getSize();
int toIndex = (page.getCurrent() - 1) * page.getSize() + page.getSize();
//判断下标是否超过集合的大小,防止下标越界
if (toIndex > personalReportList.size()) {
toIndex = personalReportList.size();
}
reportPage.setRecords(personalReportList.subList(fromIndex, toIndex));
} else {
page.setRecords(personalReportList);
}
return reportPage;
对 list 集合进行分页操作
猜你喜欢
转载自blog.csdn.net/weixin_44412272/article/details/118385348
今日推荐
周排行