当前位置:网站首页>对List集合进行分页
对List集合进行分页
2022-04-23 14:00:00 【白云碎里一蓑舟】
list分页工具
/** * 开始分页 * @param list * @param pageNum 页码 * @param pageSize 每页多少条数据 */
public static List startPage(List list, Integer pageNum, Integer pageSize) {
if (list == null) {
return null;
}
if (list.size() == 0) {
return null;
}
Integer count = list.size(); // 记录总数
Integer pageCount = 0; // 页数
if (count % pageSize == 0) {
pageCount = count / pageSize;
} else {
pageCount = count / pageSize + 1;
}
int fromIndex = 0; // 开始索引
int toIndex = 0; // 结束索引
if (!pageNum.equals(pageCount)) {
fromIndex = (pageNum - 1) * pageSize;
toIndex = fromIndex + pageSize;
} else {
fromIndex = (pageNum - 1) * pageSize;
toIndex = count;
}
List pageList = list.subList(fromIndex, toIndex);
return pageList;
}
版权声明
本文为[白云碎里一蓑舟]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_49513507/article/details/122043197
边栏推荐
猜你喜欢

1256: bouquet for algenon

大专的我,闭关苦学 56 天,含泪拿下阿里 offer,五轮面试,六个小时灵魂拷问

服务器中挖矿病毒了,屮

Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)

freeCodeCamp----arithmetic_ Arranger exercise

UML Unified Modeling Language

Un modèle universel pour la construction d'un modèle d'apprentissage scikit

趣谈网络协议

【报名】TF54:工程师成长地图与卓越研发组织打造

Program compilation and debugging learning record
随机推荐
33 million IOPs, 39 microsecond delay, carbon footprint certification, who is serious?
Spark入门基本操作
YARN线上动态资源调优
MySQL 修改主数据库
try --finally
Program compilation and debugging learning record
Reading notes: meta matrix factorization for federated rating predictions
L2-024 部落 (25 分)
JS brain burning interview question reward
Leetcode | 38 appearance array
剑南春把文字游戏玩明白了
程序编译调试学习记录
JS 力扣刷题 103. 二叉树的锯齿形层序遍历
Express ② (routing)
Postman reference summary
Business case | how to promote the activity of sports and health app users? It is enough to do these points well
JMeter pressure test tool
[code analysis (3)] communication efficient learning of deep networks from decentralized data
力扣刷题 101. 对称二叉树
Atcoder beginer contest 248c dice sum (generating function)