国产探花免费观看_亚洲丰满少妇自慰呻吟_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>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荆门市| 新龙县| 穆棱市| 筠连县| 兴城市| 洮南市| 抚远县| 汶川县| 休宁县| 淮滨县| 天津市| 花莲县| 安阳县| 宜丰县| 陇西县| 临洮县| 清徐县| 棋牌| 育儿| 淮北市| 克拉玛依市| 区。| 英超| 沭阳县| 广南县| 高清| 苍南县| 额济纳旗| 蕉岭县| 康马县| 监利县| 封丘县| 汤原县| 荥经县| 松原市| 资兴市| 墨玉县| 永春县| 定南县| 阳高县| 望江县|