当前位置:网站首页>对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
边栏推荐
- Expression「Func「TSource, object」」 转Expression「Func「TSource, object」」[]
- Android 面试主题集合整理
- [code analysis (5)] communication efficient learning of deep networks from decentralized data
- Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
- AtomicIntegerArray源码分析与感悟
- 2022年江西最新建筑八大员(质量员)模拟考试题库及答案解析
- L2-024 tribe (25 points)
- Problems encountered in the project (V) understanding of operating excel interface poi
- Basic knowledge learning record
- JS force deduction brush question 102 Sequence traversal of binary tree
猜你喜欢
随机推荐
Scientists say Australian plan to cull up to 10,000 wild horses doesn’t go far enough
websocket
Special test 05 · double integral [Li Yanfang's whole class]
[code analysis (5)] communication efficient learning of deep networks from decentralized data
MySQL 修改主数据库
【项目】小帽外卖(八)
The latest development of fed digital currency
Express ② (routage)
crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
[code analysis (2)] communication efficient learning of deep networks from decentralized data
China creates vast research infrastructure to support ambitious climate goals
基于Ocelot的gRpc网关
Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
收藏博客贴
AtCoder Beginner Contest 248C Dice Sum (生成函数)
[code analysis (4)] communication efficient learning of deep networks from decentralized data
Android 面试主题集合整理
Neuron and neural network
STM32学习记录0007——新建工程(基于寄存器版)
elmo(BiLSTM-CRF+elmo)(Conll-2003 命名实体识别NER)