当前位置:网站首页>Paging the list collection
Paging the list collection
2022-04-23 16:48:00 【A coir boat in the broken white clouds】
list Paging tools
/** * Start paging * @param list * @param pageNum Page number * @param pageSize How many pieces of data per page */
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(); // Record the total number
Integer pageCount = 0; // the number of pages
if (count % pageSize == 0) {
pageCount = count / pageSize;
} else {
pageCount = count / pageSize + 1;
}
int fromIndex = 0; // Start index
int toIndex = 0; // End index
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;
}
版权声明
本文为[A coir boat in the broken white clouds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231400068418.html
边栏推荐
- Phpstudy V8, a commonly used software for station construction 1 graphic installation tutorial (Windows version) super detailed
- 聊一聊浏览器缓存控制
- Sail soft implements a radio button, which can uniformly set the selection status of other radio buttons
- Quick install mongodb
- Execution plan calculation for different time types
- [pimf] openharmony paper Club - what is the experience of wandering in ACM survey
- PostgreSQL列存与行存
- 关于局域网如何组建介绍
- How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
- STM32__03—初识定时器
猜你喜欢

English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)

How to choose the wireless gooseneck anchor microphone and handheld microphone scheme

Use case labeling mechanism of robot framework

MySql主从复制

英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)

Sail soft implements a radio button, which can uniformly set the selection status of other radio buttons

Creation of RAID disk array and RAID5

1959年高考数学真题

Loggie source code analysis source file module backbone analysis

扫码登录的原理你真的了解吗?
随机推荐
Talk about browser cache control
vscode如何比较两个文件的异同
Project framework of robot framework
Loading order of logback configuration file
On the security of key passing and digital signature
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
loggie 源码分析 source file 模块主干分析
How much do you know about the process of the interview
Quick install mongodb
深度学习100例 | 第41天-卷积神经网络(CNN):UrbanSound8K音频分类(语音识别)
安装及管理程序
Getting started with JDBC
DanceNN:字节自研千亿级规模文件元数据存储系统概述
Database dbvisualizer Pro reported file error, resulting in data connection failure
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
如何用Redis实现分布式锁?
Creation of RAID disk array and RAID5
G008-hwy-cc-estor-04 Huawei Dorado V6 storage simulator configuration
Introduction to new functions of camtasia2022 software
Pytorch: the pit between train mode and eval mode