代码如下,直接复制即可
public List<RiskRankForUnitVo> handleListPage(List<RiskRankForUnitVo> list, int currentPage , int pageSize) {
int totalCount = list.size(); //总数量
int pageCount = 0; //总页数
List<RiskRankForUnitVo> subyList = null;
int m = totalCount % pageSize;
if (m > 0) {
pageCount = totalCount / pageSize + 1;
} else {
pageCount = totalCount / pageSize;
}
if (m == 0) {
subyList = list.subList((currentPage - 1) * pageSize, pageSize * (currentPage));
} else {
if (currentPage == pageCount) {
subyList = list.subList((currentPage - 1) * pageSize, totalCount);
}
if (currentPage< pageCount){
subyList = list.subList((currentPage - 1) * pageSize, pageSize * (currentPage));
}
}
if (currentPage >pageCount){
return null;
}
return subyList;
}