TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
<%@ page contentType="text/HTML; charset=gb2312" %> <%
/*
Inberkong
inber520@yahoo.com.cn
QQ:27096282
数组分页技术
arrayTest.jsp */
String [] contentArray={};
contentArray=new String[125];
for(int i=0;i<125;i++)
{
contentArray="ayyayValue"+String.valueOf(i);
}
int intRowCount; //记录总数 125
int intPage=-1; //待显示页码
int intPageCount; //总页数
int intPageSize; //一页显示的记录数 6
intPageSize = 6; if(request.getParameter("pages")==null)
intPage=1;
else
intPage=Integer.parseInt(request.getParameter("pages")); intRowCount=125;//记录总数
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize; int startRecord=(intPage-1)*intPageSize;
int endRecord=(intPage*intPageSize-1);
while(startRecord<=endRecord && startRecord<=(intRowCount-1))
{
out.print("contentArray["+startRecord+"]:"+contentArray[startRecord]+"<BR>");
startRecord=startRecord+1;
}
%>
<table width="77%" height="15" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td width="43%" bgcolor="#CCCCCC"></td>
<td width="57%" bgcolor="#CCCCCC"><a href="?pages=1" >首页</a>
<%
if((intPage-1)<1)
out.print("上一页");
else
out.print("<a href="?pages="+(intPage-1)+"">上一页</a>");
%>
<%
if(intPage<intPageCount)
out.print("<a href="?pages="+(intPage+1)+"">下一页</a>");
else
out.print("下一页");
%>
<a href="?pages=<%=intPageCount%>"> 尾页</a></td>
</tr>
</table>
源码下载:http://file.javaxxz.com/2014/10/1/151917578.zip |
|