最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > jsp教程

详细的jsp分页(oracle+jsp+apache)

日期:12-25    来源:中国设计秀    作者:cnwebshow.com

我的一个详细的jsp分页程序!(Oracle+jsp+apache) UmE中国设计秀
一 前提 UmE中国设计秀
希望最新的纪录在开头给你的表建立查询:UmE中国设计秀
表:mytable UmE中国设计秀
查询:create or replace view as mytable_view from mytable order by id desc 其中,最好使用序列号create sequence mytable_sequence 来自动增加你的纪录id号UmE中国设计秀

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

ResultSet rs=stmt.executeQuery("select * from mytable_view"); UmE中国设计秀
String sqlcount="select count(*) from mytable_view"; UmE中国设计秀
ResultSet rscount=stmtcount.executeQuery(sqlcount);UmE中国设计秀

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

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

//下面是 第几页等 UmE中国设计秀
<form name="sinfo" method="post" action="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>" onSubmit="return testform(this)"> UmE中国设计秀
第<%=currPage%>页 共<%=pageCount%>页 共<%=rowCount%>条 UmE中国设计秀
<%if(currPage>1){%><a href="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>">首页</a><%}%> UmE中国设计秀
<%if(currPage>1){%><a href="sbinfo_index.jsp?page=<%=currPage-1%>&condition=<%=condition%>&type=<%=type%>">上一页</a><%}%> UmE中国设计秀
<%if(currPage<pageCount){%><a href="sbinfo_index.jsp?page=<%=currPage+1%>&condition=<%=condition%>&type=<%=type%>">下一页</a><%}%> UmE中国设计秀
<%if(pageCount>1){%><a href="sbinfo_index.jsp?page=<%=pageCount%>&condition=<%=condition%>&type=<%=type%>">尾页</a><%}%> UmE中国设计秀
跳到<input type="text" name="page" size="4" style="font-size:9px">页 UmE中国设计秀
<input type="submit" name="submit" size="4" value="GO" style="font-size:9px"> UmE中国设计秀
</form> UmE中国设计秀
 UmE中国设计秀

 完UmE中国设计秀

本文引用地址:/bc/article_46612.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明