2010寫的一個jsp分頁標簽, 基本能實現(xiàn)任何效果分頁(如谷歌, 百度分頁, AJAX分頁等), 并且能保存查詢參數(shù), 自認為比較強大, 下面記錄使用方法:
先上一個效果:

1. pagebar.jar加入lib
IConditionHelper helper = ConditionHelper.getInstance(ServletActionContext.getRequest());
UserLstReq userLstReq = new UserLstReq();
userLstReq.setUserName(userName);
userLstReq.setBeginIndex(helper.getBeginIndex());
userLstReq.setPageSize(helper.getPageSize());
helper.getCondition(userLstReq, UserLstReq.class);
UserLstRes res = userService.queryUsers(userLstReq);
HttpServletRequest request = ServletActionContext.getRequest();
request.setAttribute("list", res.getResultLst());
request.setAttribute("page", new BasePageBarBean(helper, res.getCount()));
3. jsp代碼(最好是寫在一jsp里, 再include方便更改)
<%@ taglib uri="http://www.huiwanpeng.com" prefix="p"%>
<p:pagebar totalRowCount="${page.totalRowCount}" action="${page.action}" pageSize="${page.pageSize}" currentPageNum="${page.currentPageNum}" disableCss="color:green">
總行數(shù)#totalRowCount# |
總頁數(shù)#totalPageCount# |
當前第#currentPageNum#頁 |
每頁數(shù)#pageSize# |
<a onclick="#callFirstPageFun#">第一頁</a>|
<a onclick="#callForePageFun#" style="#forePageDisableCss#">上一頁</a>|
<a onclick="#callNextPageFun#" style="#nextPageDisableCss#">下一頁</a> |
<a onclick="#callLastPageFun#">最后頁</a>
<p:loop positiveStep="2" negativeStep="4" isFill="true" currentPageCss="color:red">
<a style="#currentPageCss#" onclick="#callLoopPageFun#">#currentPageNum# </a>
</p:loop>
<input id="#inputPageNumId#" type="text" style="width:20px"/><input type="button" value="go" onclick="#callGoFun#"/>
</p:pagebar>
先上一個效果:

1. pagebar.jar加入lib
2. action里代碼(最少只需要加入3行代碼):














3. jsp代碼(最好是寫在一jsp里, 再include方便更改)














