以下是有关分页的一部分代码,一页的表格只能是24行,可以分任意多的页.
<%
int liPageHeight = 650;
int liPages = 1;
int liRowHeight = 24;
int liHeight = 54;
%>
<html>
<body oncontextmenu="return false;" ondragstart="return false;" onmousewheel="return false;">
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" height="<%=liPageHeight%>" width="760" id="Page_<%=liPages%>">
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center" height=50>
<tr>
<td class="td" height="48">
<div align="center">Table Information</div>
</td>
</tr>
<tr>
<td>
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0" class="table_print_style_small">
<tr align="center" valign="top" bgcolor="#EDF4E9">
<td width="80" height="24" valign="middle"><div align="center">ID</div></td>
<td height="24" valign="middle"> <div align="center">Name</div></td>
</tr>
<%
String lsTrID = "";
for(int i = 0;i<loGroupID.length;i++) {
String lsGroupId = (String)loGroupID[i];
String lsGroupName = m_oInfo.m_oGroupInfo.getGroupName(lsGroupId.trim()).trim();
liHeight += liRowHeight;
if (i % 24 ==0 && i!=0){
liPages++;
liHeight = 6;
lsTrID = "style=\"page-break-before : always;\" id=Page_" + liPages;
%>
<tr><td colspan="2" height="216" style="border-bottom-style :none;" class="table_print_bk_color"></td></tr>
<tr <%=lsTrID%>><td colspan="2" style="border-top-style :none;" height="72" class="table_print_bk_color"></td></tr>
<%
} else {
lsTrID = "";
}
%>
<tr>
<td width="80" height="24" align="center"><%=lsGroupId%></td>
<td height="24" align="left" ><%=Convert.convertHtmlStr(lsGroupName)%></td>
</tr>
<%
}
%>
</table>
</td>
</tr>
<%if(loGroupID.length % 24!=0){
for(int j=0;j<(27-loGroupID.length % 24);j++){%>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<%}
}%>
</table>
</td>
</tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
parent.PageCount = <%=liPages%>;
parent.showPage(0);
//-->
</SCRIPT>
</body>
</html>
<%
int liPageHeight = 650;
int liPages = 1;
int liRowHeight = 24;
int liHeight = 54;
%>
<html>
<body oncontextmenu="return false;" ondragstart="return false;" onmousewheel="return false;">
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" height="<%=liPageHeight%>" width="760" id="Page_<%=liPages%>">
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center" height=50>
<tr>
<td class="td" height="48">
<div align="center">Table Information</div>
</td>
</tr>
<tr>
<td>
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0" class="table_print_style_small">
<tr align="center" valign="top" bgcolor="#EDF4E9">
<td width="80" height="24" valign="middle"><div align="center">ID</div></td>
<td height="24" valign="middle"> <div align="center">Name</div></td>
</tr>
<%
String lsTrID = "";
for(int i = 0;i<loGroupID.length;i++) {
String lsGroupId = (String)loGroupID[i];
String lsGroupName = m_oInfo.m_oGroupInfo.getGroupName(lsGroupId.trim()).trim();
liHeight += liRowHeight;
if (i % 24 ==0 && i!=0){
liPages++;
liHeight = 6;
lsTrID = "style=\"page-break-before : always;\" id=Page_" + liPages;
%>
<tr><td colspan="2" height="216" style="border-bottom-style :none;" class="table_print_bk_color"></td></tr>
<tr <%=lsTrID%>><td colspan="2" style="border-top-style :none;" height="72" class="table_print_bk_color"></td></tr>
<%
} else {
lsTrID = "";
}
%>
<tr>
<td width="80" height="24" align="center"><%=lsGroupId%></td>
<td height="24" align="left" ><%=Convert.convertHtmlStr(lsGroupName)%></td>
</tr>
<%
}
%>
</table>
</td>
</tr>
<%if(loGroupID.length % 24!=0){
for(int j=0;j<(27-loGroupID.length % 24);j++){%>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<%}
}%>
</table>
</td>
</tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
parent.PageCount = <%=liPages%>;
parent.showPage(0);
//-->
</SCRIPT>
</body>
</html>
int row=2;//每页两条
String sPage = request.getParameter("sPage");//第几页
int iPage=Integer.parseInt(sPage);
int x=0;
if(aa.length>=(iPage+1)*row-1){
x=(iPage+1)*row-1;
}else{
x=aa.length;
}for(int i=iPage*row-1;i<x;i++)
{
out.println(aa[!]);
}