下面的代码是一个java方法,没有包含在类内部,如果使用的话,请写一个类包装起来,然后在掉就OK了
/**'**************************************************
'showpageliang20050329
'作 用:显示“上一页 下一页”等信息
'参 数:sfilename ----链接地址
' totalnumber ----总数量
' maxperpage ----每页数量
' ShowTotal ----是否显示总数量
' ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
' strUnit ----计数单位
'**************************************************
*/
public String ee_showpage(String sfilename, int totalnumber, int maxperpage, boolean ShowTotal, boolean ShowAllPages, String strUnit, int page) {
int n, i;
totalnumber=totalnumber;
String strTemp, strUrl;
if (totalnumber % maxperpage == 0)
n = totalnumber / maxperpage;
else
n = totalnumber / maxperpage + 1;
strTemp = "<table align='center'><tr><td>";
if (ShowTotal == true)
strTemp = strTemp + "共 <b>" + totalnumber + "</b> " + strUnit + " ";
strUrl = sfilename + "&";
if (page < 2)
strTemp = strTemp + "首页 上一页 ";
else {
strTemp = strTemp + "<a href='" + strUrl + "currpage=1'>首页</a> ";
strTemp = strTemp + "<a href='" + strUrl + "currpage=" + (page - 1) + "'>上一页</a> ";
}
if (n - page < 1)
strTemp = strTemp + "下一页 尾页";
else {
strTemp = strTemp + "<a href='" + strUrl + "currpage=" + (page + 1) + "'>下一页</a> ";
strTemp = strTemp + "<a href='" + strUrl + "currpage=" + n + "'>尾页</a>";
}
strTemp = strTemp + " 页次:<strong><font color=red>" + page + "</font>/" + n + "</strong>页 ";
strTemp = strTemp + " <b>" + maxperpage + "</b>" + strUnit + "/页";
if (ShowAllPages == true)
strTemp = strTemp + " 转到:<select name='page' size='1' οnchange=javascript:window.location='" + strUrl + "currpage=" + "'+this.options[this.selectedIndex].value;>";
StringBuffer sb = new StringBuffer(strTemp);
for (int ii = 1; ii <= n; ii++) {
sb.append("<option value='");
sb.append(ii);
sb.append("'");
if (page == ii) {
sb.append(" selected ");
}
sb.append(">第");
sb.append(ii);
sb.append("页</option>");
}
sb.append("</select></td></tr></table>");
return sb.toString();
}