<%
//變量聲明
java
java
java
java
java
int intPageSize; //一頁顯示的記錄數
int intRowCount; //記錄總數
int intPageCount; //總頁數
int intPage; //待顯示頁碼
int layer;
int idlayer;
idlayer=
java
outtext=”";
java
int j;
int i;
//設置一頁顯示的記錄數
intPageSize =
//取得待顯示頁碼
strPage = request
if(strPage==null){//表明在QueryString中沒有page這一個參數
intPage =
}
else{//將字符串轉換成整型
intPage = java
if(intPage<
}
//裝載JDBC驅動程序
Class
//連接數據庫
sqlCon = java
//創建語句對象
sqlStmt = sqlCon
//執行SQL語句並獲取結果集
sqlRst = sqlStmt
//獲取記錄總數
sqlRst
intRowCount = sqlRst
//記算總頁數
intPageCount = (intRowCount+intPageSize
//調整待顯示的頁碼
if(intPage>intPageCount) intPage = intPageCount;
%>
<html>
<head>
<meta http
<base target=”contents”>
<LINK rel=”stylesheet” href=”css
<script language=”JavaScript”>
function byteLen(str) {
var iByteLen =
if (str == null || str == “”) {
iByteLen =
} else {
for (var i =
if(str
iByteLen++;
} else {
iByteLen +=
}
}
}
return iByteLen;
}
</script>
</head>
<body topmargin=”
<table width=”
>> 分頁
<form method=post action=”pink
<input type=submit value=”首 頁”>
</form>
<%if(intPage>
%>
<form method=post action=”pink
<input type=submit value=上一頁>
</form>
<%}%>
<%if(intPage<intPageCount)
{%>
<form method=post action=”pink
<input type=submit value=下一頁>
</form>
<%}%>
<form method=post action=”pink
<input type=submit value=”尾 頁”>
</form>
頁次
</td></tr></table>
<table>
<td width=”%
if(intPageCount>
sqlRst
i =
while(i<intPageSize && !sqlRst
String names = sqlRst
String use_xi = sqlRst
%>
<li><%=names%>
<%
sqlRst
i++;
}
}
%>
</ul></td></table>
</body>
</html>
<%
//關閉結果集
sqlRst
//關閉SQL語句對象
sqlStmt
//關閉數據庫
sqlCon
%>
——————
If the resultset is empty
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19819.html