:在ORACLE大数据量下的分页解决方法。一般用截取ID方法,还有是三层嵌套方法。下面的是网上的答案,不过没有看明白,那讲一下,弄细点,<%
int i=1;
int numPages=14;
String pages = request.getParameter(page) ;
int currentPage = 1;
currentPage=(pages==null)?(1):{Integer.parseInt(pages)}
sql = select count(*) from tables;
ResultSet rs = DBLink.executeQuery(sql) ;
while(rs.next()) i = rs.getInt(1) ;
int intPageCount=1;
intPageCount=(i%numPages==0)?(i/numPages)i/numPages+1);
int nextPage ;
int upPage;
nextPage = currentPage+1;
if (nextPage>=intPageCount) nextPage=intPageCount;
upPage = currentPage-1;
if (upPage<=1) upPage=1;
rs.close();
sql=select * from tables;
rs=DBLink.executeQuery(sql);
i=0;
while((i<numpages*(currentpage-1))&&rs.next()){i++;} <br="">%>
//输出内容
//输出翻页连接
合计:<%=currentPage%>/<%=intPageCount%>第一页href=List.jsp?page=<%=upPage%>>上一页
<%
for(int j=1;j<=intPageCount;j++){
if(currentPage!=j){
%>
>[<%=j%>]
<%
}else{
out.println(j);
}
}
%>
>下一页>最后页
为什么会有
<%
for(int j=1;j<=intPageCount;j++){
if(currentPage!=j){
%>
>[<%=j%>]
<%
}else{
out.println(j);
}
}
%>
这一段呢?他是做什么的呀,那个高手可以说说每一个代码的意思,不光是我问的这个,把上的都解释一下了
oracle面试
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
6条回答 默认 最新
- 「已注销」 2008-11-05 23:19关注
<%
int i=1;
int numPages=14;//每页的记录数
String pages = request.getParameter(page) ; // 取出当前页码参数
int currentPage = 1;
currentPage=(pages==null)?(1):{Integer.parseInt(pages)} //转换成数字
sql = select count(*) from tables;
ResultSet rs = DBLink.executeQuery(sql) ;
while(rs.next()) i = rs.getInt(1) ; //连接数据库,查询总记录数
int intPageCount=1;
intPageCount=(i%numPages==0)?(i/numPages)i/numPages+1);//计算出总页数
int nextPage ;
int upPage;
nextPage = currentPage+1;
if (nextPage>=intPageCount) nextPage=intPageCount;//下页的页码
upPage = currentPage-1;
if (upPage<=1) upPage=1;//上页的页码
rs.close();
sql=select * from tables;
rs=DBLink.executeQuery(sql);
i=0;
while((i %>
//输出内容
//输出翻页连接
合计:<%=currentPage%>/<%=intPageCount%>第一页 href=List.jsp?page=>上一页
<%
for(int j=1;j<=intPageCount;j++){
if(currentPage!=j){
%>
>[<%=j%>]//其实page作为一个页码的参数
<%
}else{
out.println(j);
}
}
%>
>下一页>最后页为什么会有
<%
for(int j=1;j<=intPageCount;j++){
if(currentPage!=j){
%>
>[<%=j%>]
<%
}else{
out.println(j);
}
}
%>
这段存在是因为,这个页码除了显示上一页,下一页,还显示第x页的功能,看看javaeye论坛的分页那个样子。而且当前页是不做连接处理。。。ok,还有什么问题?
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥20 易康econgnition精度验证
- ¥15 线程问题判断多次进入
- ¥15 msix packaging tool打包问题
- ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
- ¥15 python的qt5界面
- ¥15 无线电能传输系统MATLAB仿真问题
- ¥50 如何用脚本实现输入法的热键设置
- ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
- ¥30 深度学习,前后端连接
- ¥15 孟德尔随机化结果不一致