<%
/*
Inberkong
Inber520@yahoo.com.cn
QQ: 27096282
Array paging technology
Arraytest. jsp
*/
String [] contentarray = {};
Contentarray = new string [125];
For (INT I = 0; I <125; I ++)
{
Contentarray [I] = "ayyayvalue" + String. valueof (I );
}
Int introwcount; // a total of 125 records
Int intpage =-1; // page number to be displayed
Int intpagecount; // the total number of pages.
Int intpagesize; // The number of records displayed on one page is 6.
Intpagesize = 6;
If (request. getparameter ("pages") = NULL)
Intpage = 1;
Else
Intpage = integer. parseint (request. getparameter ("pages "));
Introwcount = 125; // total number of records
// Calculate the total number of pages
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 "> homepage </a>
<%
If (intPage-1) <1)
Out. Print ("Previous Page ");
Else
Out. Print ("<a href = '? Pages = "+ (intPage-1) +" '> previous page </a> ");
%>
<%
If (intpage <intpagecount)
Out. Print ("<a href = '? Pages = "+ (intpage + 1) +" '> next page </a> ");
Else
Out. Print ("next page ");
%>
& Nbsp; <a href = '? Pages = <% = intpagecount %> '> last page </a> </TD>
</Tr>
</Table>