学习坊广告 网站建设咨询电话0711-5903333 、 QQ:215665888        将学习坊设为主页     广告赞助QQ:410899793     主页申请

详细的jsp分页

来源:网络 【www.cn0711.net】   作者:未知【学习坊转】 [字体: ]


我的一个详细的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>





 

录入:学习坊

查看对 详细的jsp分页 的评论 【 发表见解 】 【 查看见解 】 【 打印资料 】  
上一篇:Sun认为C#不会替代Java
下一篇:js与applet的相互调用
百度中>“详细的jsp分页”相关内容 google中>“详细的jsp分页”相关内容
雅虎中>“详细的jsp分页”相关内容 搜狗中>“详细的jsp分页”相关内容
中搜中>“详细的jsp分页”相关内容 爱问中>“详细的jsp分页”相关内容