<%
//分页显示
int num = 0;
int countall = infolist.size();//总数
int pageSize = 28;//每页数量
int pageCount;//总共页数
int pageNo = 1;//当前页号
int mixNum; //当前页数据开始号
int maxNum;
String pNO = request.getParameter("pageNo");
if((pNO != null) && (!pNO.equals(""))){
pageNo=Integer.parseInt(pNO);
}
if (countall > pageSize) {
if ((countall / pageSize) * pageSize < countall) {
pageCount = (countall / pageSize) + 1;
}
else{
pageCount = (countall / pageSize);
}
}
else if (countall / pageSize == 1) {
pageCount = 1;
}
else {
pageCount = 1;
}
if (pageNo >= pageCount) {
pageNo = pageCount;
}
else if (pageNo < 1) {
pageNo = 1;
}
mixNum = (pageNo-1) * pageSize;
maxNum = pageNo*pageSize;
if((mixNum + pageSize) > countall){
maxNum = countall;
}
else{
maxNum = mixNum+pageSize;
}
%>
---------------------------------------------------------------------------------------------
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function check(){
if(Jtrim(document.forms.meslistForm.textfield.value)==""){
alert("请输入页数");
}
else if(checkNum(document.forms.meslistForm.textfield.value)){
window.location.href="?pageNo="+document.forms.meslistForm.textfield.value;
}else{
alert("请输入数字。");
}
document.forms.meslistForm.textfield.value = "";
document.forms.meslistForm.textfield.select();
}
function checkNum(str){
return str.match(/\D/)==null;
}
function Jtrim(str)
{
var i = 0;
var len = str.length;
if ( str == "" ) return( str );
j = len -1;
flagbegin = true;
flagend = true;
while ( flagbegin == true && i< len)
{
if ( str.charAt(i) == " " )
{
i=i+1;
flagbegin=true;
}
else
{
flagbegin=false;
}
}
while (flagend== true && j>=0)
{
if (str.charAt(j)==" ")
{
j=j-1;
flagend=true;
}
else
{
flagend=false;
}
}
if ( i > j ) return ("")
trimstr = str.substring(i,j+1);
return trimstr;
}</script>
</head>
<body>
<%
for(int i=mixNum;i<maxNum;i++){
//此处用list循环下标用i
}
%>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4%" height="27" align="center" valign="middle"
class="word"> </td>
<td width="56%" align="center" valign="middle" class="word"><img
src="<%=path%>/images/pagination/list_home.gif" width="13"
height="13"> <%
if (pageNo > 1) {
%> <a href="?pageNo=1"> 首页</a>
<%
}else{
%> 首页 <%
}
%> <img src="<%=path%>/images/pagination/list_pre.gif"
width="13" height="13"> <%
if (pageNo > 1) {
%> <a href="?pageNo=<%=(pageNo-1)%>"> 前一页</a>
<%
}else{
%> 前一页 <%
}
%> <img
src="<%=path%>/images/pagination/list_next.gif" width="13"
height="13"> <%
if (pageCount>pageNo) {
%> <a href="?pageNo=<%=(pageNo+1)%>"> 后一页</a>
<%
}else{
%> 后一页 <%
}
%> <img src="<%=path%>/images/pagination/list_end.gif"
width="13" height="13"> <%
if (pageCount>pageNo) {
%> <a href="?pageNo=<%=(pageCount)%>"> 尾页</a> <%
}else{
%> 尾页 <%
}
%>
<td width="26%" align="center" valign="middle" class="word">共<%=pageCount%>页 第<%=pageNo%>页
跳转</td>
<td width="4%" align="center" valign="middle" class="word"><input
name="textfield" type="text" class="input" size="1"></td>
<td width="6%" align="center" valign="middle" class="word"><a
href="javascript:check()"><img
src="<%=path%>/images/pagination/go.gif" border="0" width="18"
height="18"></a></td>
<td width="4%" align="left" valign="middle" class="word"> </td>
</tr>
</table></body>
</html>