站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Java 专题jsp 数组分页显示

jsp 数组分页显示

摘要: jsp 数组分页显示

</td> </tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="450" height="86" align="left" valign="top"><%@ 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[i]="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]+"
");
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">首页

<%
if((intPage-1)<1)
out.print("上一页");
else
out.print("上一页");
%>

<%
if(intPage out.print("下一页");
else
out.print("下一页");
%>
&nbsp;'> 尾页</td>
</tr>
</table>

</td> <td width="234" valign="top"> </td> </tr> </table> </td> </tr> <tr>


↑返回目录
前一篇: 多用户网站统计系统
后一篇: 应用JAVA数据库连接池技术提高电子商务网站性能