[100分]求分页显示的解决好的思路....

xzhljsp 2004-10-15 01:00:43
同上
...全文
354 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
baffling 2004-11-02
  • 打赏
  • 举报
回复
gz
panzi667 2004-10-21
  • 打赏
  • 举报
回复
学习
dafei0320 2004-10-21
  • 打赏
  • 举报
回复
如果查询简单的话还可以!但是如果查询语句很复杂-那计算纪录个数和下面的查询各个纪录的SQL语句要写的一样--很麻烦啊-^@^
Ronanljy 2004-10-21
  • 打赏
  • 举报
回复
就在论坛上搜索一下,会出来一大片的。

我都回答过好几个相同的解决方案了,不想在说了……
xzhljsp 2004-10-21
  • 打赏
  • 举报
回复
用MYSQL怎么每下读10行啊

我对SQL不太会
kui 2004-10-17
  • 打赏
  • 举报
回复
可选择JavaWebStudio,部分用法可参考一下面:
《《如何实现Struts 数据库应用程序》
《如何在Struts 数据库应用程序中实现分页显示》
《如何在Struts 数据库应用程序中实现记录的删除、更新及链接》
《如何在Struts 数据库应用程序中实现记录的添加》
《如何建立一个带登陆页面的Struts数据库应用程序》
《如何建立一个带登陆页面及角色的Struts数据库应用程序》


http://dev.csdn.net/user/kui
http://javaweb.51.net/
http://javawebStudio.51.net/

下载《Struts开发实例》地址:
http://www.infoxa.com/asp/book/xxnr.asp?id=1333
1by1 2004-10-17
  • 打赏
  • 举报
回复
简而言之,分页的优化就是一下子从数据库多读几页,比如10页,放在session中,然后按下一页就能快点了。
cheyo车油 2004-10-17
  • 打赏
  • 举报
回复
本版FAQ里有一个帖子讨论分页的,你可以去看看

个人觉得还是交给数据库来实现比较方便和简捷啊
panzi667 2004-10-17
  • 打赏
  • 举报
回复
学习
redez 2004-10-15
  • 打赏
  • 举报
回复
我的一个详细的jsp分页程序!(oracle+jsp+apache)
一 前提
希望最新的纪录在开头给你的表建立查询:
表:mytable
查询:create or replace view as mytable_view from mytable order by id desc 其中,最好使用序列号create sequence mytable_sequence 来自动增加你的纪录id号

二 源程序
<%String sConn="你的连接"
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(sConn,"你的用户名","密码");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

ResultSet rs=stmt.executeQuery("select * from mytable_view");
String sqlcount="select count(*) from mytable_view";
ResultSet rscount=stmtcount.executeQuery(sqlcount);

int pageSize=你的每页显示纪录数;
int rowCount=0; //总的记录数
while (rscount
int pageCount; //总的页数
int currPage; //当前页数
String strPage;
strPage=request.getParameter("page");
if (strPage==null){
currPage=1;
}
else{
currPage=Integer.parseInt(strPage);
if (currPage<1) currPage=1;
}
pageCount=(rowCount+pageSize-1)/pageSize;
if (currPage>pageCount) currPage=pageCount;

int thepage=(currPage-1)*pageSize;
int n=0;
rs.absolute(thepage+1);
while (n<(pageSize)&&!rs
%>
<%rs.close();
rscount.close();
stmt.close();
stmtcount.close();
conn.close();
%>

//下面是 第几页等
<form name="sinfo" method="post" action="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>" onSubmit="return testform(this)">
第<%=currPage%>页 共<%=pageCount%>页 共<%=rowCount%>条
<%if(currPage>1){%><a href="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>">首页</a><%}%>
<%if(currPage>1){%><a href="sbinfo_index.jsp?page=<%=currPage-1%>&condition=<%=condition%>&type=<%=type%>">上一页</a><%}%>
<%if(currPage<pageCount){%><a href="sbinfo_index.jsp?page=<%=currPage+1%>&condition=<%=condition%>&type=<%=type%>">下一页</a><%}%>
<%if(pageCount>1){%><a href="sbinfo_index.jsp?page=<%=pageCount%>&condition=<%=condition%>&type=<%=type%>">尾页</a><%}%>
跳到<input type="text" name="page" size="4" style="font-size:9px">页
<input type="submit" name="submit" size="4" value="GO" style="font-size:9px">
</form>
cnidb 2004-10-15
  • 打赏
  • 举报
回复
我用取x to y之间的内容
xzhljsp 2004-10-15
  • 打赏
  • 举报
回复
给我个思路
谢谢
llp1217 2004-10-15
  • 打赏
  • 举报
回复
看看我的blog
http://blog.csdn.net/llp1217/archive/2004/09/07/97069.aspx

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧