一、jsp页面的主要代码
/第一步
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager" %>
/第二步
<div align="center">
<pg:pager url="${path}/WoController/getWoInfoList.mmx"
items="${totalCount}" export="currentPageNumber=pageNumber" maxPageItems="20">
<pg:index>
<pg:first unless="current">
<a href="javascript:;" οnclick="reLoadData(${pageNumber }, '${pageUrl}');">首页</a>
</pg:first>
<pg:prev>
<a href="javascript:;" οnclick="reLoadData(${pageNumber }, '${pageUrl}');">前页</a>
</pg:prev>
<pg:pages>
<c:choose>
<c:when test="${currentPageNumber eq pageNumber}">
<font color="red">${pageNumber }</font>
</c:when>
<c:otherwise>
<a href="javascript:;" οnclick="reLoadData(${pageNumber }, '${pageUrl}');">${pageNumber }</a>
</c:otherwise>
</c:choose>
</pg:pages>
<pg:next>
<a href="javascript:;" οnclick="reLoadData(${pageNumber }, '${pageUrl}');">后页</a>
</pg:next>
<pg:last unless="current">
<a href="javascript:;" οnclick="reLoadData(${pageNumber }, '${pageUrl}');">尾页</a>
</pg:last>
</pg:index>
</pg:pager>
</div>
function reLoadData(page,pageUrl){
pageUrl += '&' + $('#searchForm').serialize();
$('#dataListDiv').html('数据加载中...').load(pageUrl);
}
二、后台代码(SpringMVC)
@RequestMapping("/<span style="font-family: Arial, Helvetica, sans-serif;">getWoInfoList</span><span style="font-family: Arial, Helvetica, sans-serif;">")</span>
public ModelAndView <span style="font-family: Arial, Helvetica, sans-serif;">getWoInfoList</span><span style="font-family: Arial, Helvetica, sans-serif;">(HttpServletRequest request,HttpServletResponse response) throws Exception{</span>
Map<String, Object> model = new HashMap<String, Object>();
List<Info> List = new ArrayList<Info>();
try{
//分页参数
int pageNo = ServletRequestUtils.getIntParameter(request, "pager.offset", 0);
int pageSize = ServletRequestUtils.getIntParameter(request, "pager.limit", 20);
//列表数据
List = service.getInfoList(paramMap,pageNo,pageSize);
model.put("list",list);
model.put("total",list.size());
} catch(Exception e) {
e.printStackTrace();
log.error(e.toString());
}
return new ModelAndView("order/InfoListData",model);