当前位置:网站首页>Realize news page paging
Realize news page paging
2022-07-22 21:00:00 【Pengyuyan, LongQin Bay】
Function realization decomposition
1. Number of calculation results
rs.last();
int size = rs.getRow();
You can get the number of results .
2. It needs to be divided into several pages
If a page can be put 5 Bar record , be
int pageCount = (size%5==0)?(size/5):(size/5+1);
You can get it. You need to divide it into several pages .
3. Control the number of display records specified in one page
If a page can show 5 Bar record , By using count Count .
int count = 0;
do{
if(count>=5) break;
.....
count++;
}while(rs.next());
adopt break sentence , It can make it jump out when it exceeds the specified entry .
4. How to know the current page
adopt HTTP get Characteristics , Indicate the current address in the address bar , Such as http://.......?curPage=1 It means now is the first page .
String tmp = request.getParameter("curPage");
if(tmp==null){
tmp="1";
}
curPage = Integer.parseInt(tmp);
You can get the current page .
rs.absolute((curPage-1)*PAGESIZE+1);
Adjust the result set pointer to the beginning of the record that should be displayed on the current page .
For example, if a page shows 5 Bar record , The current page is the second , You need to adjust the pointer to 6, The current page is the third , You need to adjust the pointer to 11.
5. Click home 、 The previous page 、 The next page 、 Behavior of the last page
<a href="multipage.jsp?curPage=<%curPage+1%>" > The next page </a>
<a href="multipage.jsp?curPage=<%curPage-1%>" > The previous page </a>
<a href="multipage.jsp?curPage=<%pageCount%>" > Tail page </a>
<a href="multipage.jsp?curPage=1" > home page </a>
边栏推荐
猜你喜欢
ASP.NET Core部署手册:4.注意事项和问题排查
Airtest 进行WebUI自动化测试(selenium)
多线程03--synchronized和锁升级
Redis 系列11--Redis 持久化
Likeshop100%开源无加密-B2B2C多商户商城系统!!
Wechat applet cannot read property'setdata'of null error
Charles 抓包原理与实践
Automatic generation of common centroid capacitance array with arbitrary capacitance ratio
【FPGA】:clocking核的使用
Common centroid capacitor layout generation considering device matching and parasitic minimization
随机推荐
弱网测试(Charles模拟)
Multithreading 04 -- visibility of threads
spark常见问题
【FPGA】:clocking核的使用
Airtest 进行WebUI自动化测试(selenium)
使用vis-network根据节点坐标定位环形工具栏
Bash基本功能—通配符和其他特殊符号
流程控制.
Matching of MOS transistors with different layout styles
Pastel: parasitic matching drive layout and wiring of capacitor array with generalized ratio in charge redistribution sar-adc
宏和枚举
Redis series 14 -- redis cluster
Automatic generation of common centroid capacitance array with arbitrary capacitance ratio
多线程06--CountDownLatch、CyclicBarrier、Semaphore
Leetcode high frequency question: what is the difference between the combat effectiveness of the two soldiers with the closest combat effectiveness of N soldiers in the challenge arena
Redis 系列14--Redis Cluster
Multithreading 06 -- countdownlatch, cyclicbarrier, semaphore
多线程04--线程的原子性、CAS
RPM包管理—YUM在线管理--YUM命令
Highly configurable and scalable spiral capacitor design for high-density or high-precision applications