<%
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i;
intPageSize=10;
strPage=request.getParameter("page");
if(strPage==null)
{
intPage=1;
}
else
{
intPage=java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage=1;
}
TestBean.OpenConn("js","sa","123");
String strsql="select * from lunwen";
ResultSet sqlRst = TestBean.executeQuery(strsql);
sqlRst.last();
intRowCount=sqlRst.getRow();
intPageCount=(intRowCount+intPageSize-1)/intPageSize;
if(intPage>intPageCount) intPage=intPageCount;
%>
<html>
<head>
<meta http-equiv="Content_Language" content="zh_cn">
<meta http-equiv="Content-Type" content="text/html",charset="gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>翻页程序示例</title>
</head>
<p align="center"><font size="5" color="red">翻页程序示例</font></p>
<body bgcolor="silver">
<table border="0" width="100%" cellspacing="1" cellpadding="0" height="167">
<tr>
<td width="80%" height="165" valign="top">
<table border="1" cellspacing="0" cellpadding="0" width="100%" height="81" align="center">
<tr>
<td width="10%" bgcolor="#ccffcc" height="18" align="center">编号</td>
<td width="20%" bgcolor="#ccffcc" height="18" align="center">名称</td>
<td width="20%" bgcolor="#ccffcc" height="18" align="center">发表日期</td>
<td width="25%" bgcolor="#ccffcc" height="18" align="center">作者</td>
<td width="25%" bgcolor="#ccffcc" height="18" align="center">文件名</td>
</tr>
<%
if(intPageCount>0)
{
sqlRst.absolute((intPage-1)*intPageSize+1);
i=1;
while(i<intPageSize&&!sqlRst.isAfterLast())
{
%>
<tr bgcolor=#f2f2e6>
<td width="10%" height="18" align="center"><%=i%></td>
<td width="20%" height="18" align="center"><%=sqlRst.getString(2)%></td>
<td width="20%" height="18" align="center"><%=sqlRst.getString(3)%></td>
<td width="25%" height="18" align="center"><%=sqlRst.getString(4)%></td>
<td width="25%" height="18" align="center"><%=sqlRst.getString(5)%></td>
</tr>
<%
sqlRst.next();
    i++;
}
}
%>
</table>
<table border="1" width="100%" cellspacing="0" cellpadding="0" height="20">
<tr>
<form action="PageView.jsp" method="GET">
<td height="20" bgcolor="#99ffcc" align="right">
<%
if(intPage!=1)
{
out.println("<a href=PageView.jsp?page=1>第一页</a>");
out.println("<a href=Pageview.jsp?page="+(intPage-1)+">上一页</a>");
}
if(intPage!=intPageCount)
{
out.println("<a href=PageView.jsp?page="+(intPage+1)+">下一页</a>");
out.println("<a href=PageView.jsp?page="+intPageCount+">最后一页</a>");
}
%>
页数:<font color="#FF0000"><%=intPage%>/<%=intPageCount%></font>
</form>
</tr>
</table>
</body>
</html>
<%
sqlRst.close();
%>