2010写的一个jsp分页标签, 基本能实现任何效果分页(如谷歌, 百度分页, AJAX分页等), 并且能保存查询参数, 自认为比较强大, 下面记录使用方法:
先上一个效果:

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">
总行数#totalRowCount# |
总页数#totalPageCount# |
当前第#currentPageNum#页 |
每页数#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方便更改)














