当前位置:网站首页>If paging by frame fails - solution
If paging by frame fails - solution
2022-07-21 00:04:00 【Mouse that can knock code】
When controller There is 2 And above service When , If the first page is paged by default , There will be problems .
Solution :
controller layer :
public static TableDataInfo mySetPage(List list){
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
TableDataInfo rspData =new TableDataInfo();
rspData.setCode(0);
rspData.setRows(myStartPage(list, pageNum, pageSize));
rspData.setTotal(new PageInfo(list).getTotal());
return rspData;
}
public static List myStartPage(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 != pageCount){
fromIndex =(pageNum -1)* pageSize;
toIndex = fromIndex + pageSize;
}else{
fromIndex =(pageNum -1)* pageSize;
toIndex = count;
}
List pageList = list.subList(fromIndex,toIndex);
return pageList;
}
Pagination takes effect at this time
边栏推荐
- About my writing a Book
- ES6 —— Promise VS 函数“回调地狱”
- Postgetsql set ID auto increment primary key
- . Net uses its own Di batch injection service and backgroundservice
- Correction method and code of medical gender, age and years of Education
- Successfully solved -- MySQL container command line is displayed in Chinese as??? Problems of
- Golang - restful framework go restful
- 144. Preorder traversal of binary tree
- As for the architecture design of business security platform, the top image has been explained to "me"
- Kubernetes — client-go组件
猜你喜欢
Read through the white paper on business security - four trends in the future
将流转化为数据产品
These super easy-to-use browser plug-ins are unknown to many people
Kubernetes — client-go组件
MySQL 5.7都即将停只维护了,是时候学习一波MySQL 8了
announce. Net 7 preview 6
根据子节点递归获取所有父节点集合
Introduction to kubernetes components
为什么大家说mysql数据库单表最大两千万?依据是啥?
Maintainability of data intensive application of reading notes
随机推荐
Circle Game
Es6 - - promesse vs fonction "Callback Hell"
中国大陆IP段(含港澳)【2022-07-15】
Unit meaning of network bandwidth
【Postman】使用Tests进行环境变量设置
Transform streams into data products
The savefig of Matplotlib must be before show
oracle报错解决
[ROS] handwritten message publisher and subscriber
Why do you say that the maximum single table of MySQL database is 20million? Based on what?
字節一面掛了,面試官問DDD,我卻不知道
为什么大家说mysql数据库单表最大两千万?依据是啥?
创未来,享非凡,openGauss Developer Day 2022圆满举行
不就是个TCC分布式事务,有那么难吗?
Target segmentation for 10000 frames of video, less than 1.4GB of video memory, open source code | ECCV 2022
Which platform is the best and safest to buy stocks on?
冒泡排序
医学 性别、年龄、受教育年限的校正 方法与代码
FAQ - build a business security platform architecture. Here are all the answers you want!
Data center, a new type of infrastructure that determines the driving force of the city's future development