国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

詳細的jsp分頁(oracle+jsp+apache)

2024-09-05 00:20:32
字體:
來源:轉載
供稿:網友

我的一個詳細的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" >頁
<input type="submit" name="submit" size="4" value="go" >
</form>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鄄城县| 舒城县| 自贡市| 吉安市| 曲靖市| 夏邑县| 平山县| 罗江县| 江油市| 南岸区| 华蓥市| 玛多县| 河津市| 库车县| 达拉特旗| 雷山县| 子长县| 延川县| 海淀区| 三穗县| 台东县| 株洲市| 东光县| 罗山县| 三穗县| 泽普县| 苏州市| 南阳市| 台山市| 贵定县| 济宁市| 中江县| 福建省| 古田县| 台湾省| 宜君县| 荥阳市| 彩票| 巨野县| 资阳市| 原阳县|