<%
int intpagesize; //一頁顯示的記錄數
int introwcount; //記錄總數
int intpagecount; //總頁數
int intpage; //待顯示頁碼
string strpage;
//設定一頁顯示的記錄數
intpagesize = 25;
//取得待顯示頁碼
strpage = request.getparameter("page");
if(strpage==null){//表明在querystring中沒有page這一個參數,此時顯示第一頁資料
intpage = 1;
}else{//将字元串轉換成整型
intpage = java.lang.integer.parseint(strpage);
if(intpage< 1){
}
rs=connjb.executequery(sql);
rs.absolute(1);
//擷取記錄總數
rs.last();
introwcount = rs.getrow();
//記算總頁數
intpagecount = (introwcount+intpagesize-1) / intpagesize;
//調整待顯示的頁碼
if(intpage >intpagecount) intpage = intpagecount;
if(intpagecount >0){
//将記錄指針定位到待顯示頁的第一條記錄上
rs.absolute((intpage-1) * intpagesize+1);
//顯示資料
i = 0;
while(i< intpagesize && !rs.isafterlast()){
if(!classname.equals("行業分類")){
//id=rs.getint("information_id");
strid=rs.getstring("information_id");
subjectname=rs.getstring("information_name");
informationrank=rs.getstring("information_rank");
%>
<tr>
<td width="4%" height="25" valign="middle"><div align="center">◇</div></td>
<td width="96%"><a href="index2.jsp?information_id=<%=strid%>&information_rank=<%=informationrank%>" class="t8"><%=subjectname%></a></td>
</tr>
<% }else{
strid=rs.getstring("sub_class_value");
subjectname=rs.getstring("sub_class_value");
<td width="96%"><a href="index_way.jsp?small_class=<%=strid%>" class="t8"><%=subjectname%></a></td>
<%}%>
<%
rs.next();
i++;
}rs.close();
i=0;
</table>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
<td valign="top" bgcolor="#f2f2f2">
<div align="left">
</div></td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#8c8c8c">
<td height="22" align="center" bgcolor="#ffffff">第<%=intpage%>頁 共<%//=introwcount%>條記錄/共<%=intpagecount%>頁
if(intpage<2){
out.print("首頁 | 上一頁");
}else{%>
<a href="index.jsp?class_name=<%=classname%>&subject_name=<%=titlename%>">首頁 </a> | <a href="index.jsp?page=<%=intpage-1%>&class_name=<%=classname%>&subject_name=<%=titlename%>">上一頁</a>
|
if((intpagecount-intpage)<1)
{
out.print("下一頁 | 尾頁");
<a href="index.jsp?page=<%=intpage+1%>&class_name=<%=classname%>&subject_name=<%=titlename%>">下一頁</a> | <a href="index.jsp?page=<%=intpagecount%>&class_name=<%=classname%>&subject_name=<%=titlename%>">尾頁</a>
<%}
else{
out.print("<center><table width=776 border=0 align=center cellpadding=0 cellspacing=1 bgcolor=#000000><tr><td bgcolor=#ffffff><center>目前還沒有内容!</center></td></tr></table></centre>");
}%>
其中sql為具體的sql語句.