//逻辑分页
PageModel model = new PageModel();
long total = list.size();
model.setTotal(total);
model.setPageNum(pageNum);
model.setPageSize(pageSize);
long page= total % pageSize == 0 ? total / pageSize : total/ pageSize + 1;
model.setTotalPage(page);
// 从第几条数据开始
long firstIndex;
long lastIndex;
if (pageNum > page){标签:逻辑,java,分页,pageSize,list,model,total,firstIndex,page From: https://www.cnblogs.com/eternality/p/16642563.html
firstIndex = (page - 1) * pageSize;
lastIndex = page * pageSize;
}else {
firstIndex = (pageNum - 1) * pageSize;
lastIndex = pageNum * pageSize;
}
if (list.size() < pageSize){
model.setData(list);
}else if (page <= pageNum){
model.setData(list.subList((int) firstIndex,(int)total));
} else {
model.setData(list.subList((int) firstIndex,(int) lastIndex));
}