<%
?//分頁顯示
?int num = 0;
?int countall = infolist.size();//總數(shù)
?int pageSize = 28;//每頁數(shù)量
?int pageCount;//總共頁數(shù)
?int pageNo = 1;//當前頁號
?int mixNum;?? //當前頁數(shù)據(jù)開始號
?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("請輸入頁數(shù)");
?}
?else if(checkNum(document.forms.meslistForm.textfield.value)){
??window.location.href="?pageNo="+document.forms.meslistForm.textfield.value;
?}else{
??alert("請輸入數(shù)字。");
?}
?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循環(huán)下標用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%>頁
????跳轉(zhuǎn)</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>