欢迎光临
我们一直在努力

详细的jsp分页-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 详细的jsp分页-JSP教程,Jsp/Servlet
分享到: 更多 (0)

相关推荐

  • 暂无文章