怎么在jquery中使用pagination.js实现分页?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
为海沧等地区用户提供了全套网页设计制作服务,及海沧网站建设行业解决方案。主营业务为做网站、成都网站设计、海沧网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
添加下载的js和样式,主要是先添加jquery.js 再添加jquery.pagination.js,我这是下载好的,放在本地
css/pagination.css" type="text/css">
表格,用的是c标签,获取控制器传过来的值
| 商品显示 | ||||||
|---|---|---|---|---|---|---|
| 商品编号 | 商品大类 | 商品名称 | 商品规格 | 加权进价 | 当前售价 | 操作 |
js
var limit=<%=request.getAttribute("limit")%>;//每页显示多少 条数据
var count=<%=request.getAttribute("count")%>//共多少条数据
var index=<%=request.getAttribute("index")%>;//当前记录数
$(function(){
$("#Pagination").pagination(count, {
items_per_page:limit, // 每页显示多少条记录
current_page: Math.ceil(index/limit), //当前页
num_display_entries:4, // 分页显示的条目数
next_text:"下一页",
prev_text:"上一页",
num_edge_entries:2, // 连接分页主体,显示的条目数
callback:handlePaginationClick
});
});
function handlePaginationClick(new_page_index, pagination_container) {
var path="<%=ppath%>/goodsManager/searchGoodsBylimit/" + new_page_index*limit;
$("#goodsForm").attr("action",path );
$("#goodsForm").submit();
return false;
}控制器
@RequestMapping(value = "/searchGoodsBylimit/{index}")
public String searchGoodsBylimitPst(Model model,
@ModelAttribute Goods goods, @PathVariable String index,
HttpServletRequest request) {
//索引
if (index == null || index.equals("")) {
index = "0";
//从服务器获取数据
List goodsS = goodsService.selectGoods(goods,
Integer.parseInt(index), PageParam.limit);
if (goodsS != null) {
model.addAttribute("goodsS", goodsS);
} else {
model.addAttribute("resultMsg", "没有该商品");
}
//数据总条数
int count = goodsService.selectAllCount(goods);
model.addAttribute("index", index);
model.addAttribute("count", count);
model.addAttribute("limit", PageParam.limit);
System.out.println("第" + index + "数据开始显示" + goodsS.size() + "条记录");
return "goodsManager/showGoods";
} 效果图

关于怎么在jquery中使用pagination.js实现分页问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。