jquery.pagination.js分页使用教程


Posted in jQuery onOctober 23, 2018

简单介绍一下在动态网页里面的jquery.pagination.js分页的使用,具体内容如下

添加下载的js和样式,主要是先添加jquery.js 再添加jquery.pagination.js,我这是下载好的,放在本地

<link rel="stylesheet" href="<%=path%>css/pagination.css" type="text/css">
<script type="text/javascript" src="<%=path%>js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="<%=path%>js/jquery.pagination.js"></script>

表格,用的是c标签,获取控制器传过来的值

<table width="1052" border=0 align=center cellpadding=2 cellspacing=1
   bordercolor="#799AE1" class=tableBorder>
   <tbody>
    <tr>
     <th align=center colspan=16 style="height: 23px">商品显示</th>
    </tr>

    <tr align="center" bgcolor="#799AE1" style="height:28px">
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品编号</td>
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品大类</td>
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品名称</td>
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品规格</td>
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>加权进价</td>
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>当前售价</td>
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>操作</td>

    </tr>


    <c:forEach items="${goodsS}" var="goods">
     <tr bgcolor="#DEE5FA">
      <td align="center" id="goodsId" class="txlrow"><c:out
        value="${goods.goodsId}"></c:out></td>
      <td align=center id="goodsType" class=txlrow><c:out
        value="${goods.goodsType}"></c:out></td>
      <td align=center id="goodsName" class=txlrow><c:out
        value="${goods.goodsName}"></c:out></td>
      <td align=center id="goodsContent" class=txlrow><c:out
        value="${goods.goodsContent}"></c:out></td>
      <td align=center id="goodsPrice" class=txlrow><c:out
        value="${goods.goodsPrice}"></c:out></td>
      <td align=center id="goodsSell" class=txlrow><c:out
        value="${goods.goodsSell}"></c:out></td>
      <td align=center class=txlrow> <input type="button" value="编辑"></td>
     </tr>
    </c:forEach>

   </tbody>
  </table>

<!--分页显示-->
<div id="Pagination"></div>

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<Goods> 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分页使用教程

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

jQuery 相关文章推荐
为Jquery EasyUI 组件加上清除功能的方法(详解)
Apr 13 jQuery
jQuery简介_动力节点Java学院整理
Jul 04 jQuery
jQuery EasyUI结合zTree树形结构制作web页面
Sep 01 jQuery
认识jQuery的Promise的具体使用方法
Oct 10 jQuery
jQuery简单实现对数组去重及排序操作实例
Oct 31 jQuery
jquery实现回车键触发事件(实例讲解)
Nov 21 jQuery
jQuery实现简单的下拉菜单导航功能示例
Dec 07 jQuery
jQuery 改变P标签文本值方法
Feb 24 jQuery
详解JavaScript原生封装ajax请求和Jquery中的ajax请求
Feb 14 jQuery
jquery中为什么能用$操作
Jun 18 jQuery
jquery树形插件zTree高级使用详解
Aug 16 jQuery
jQuery 选择方法及$(this)用法实例分析
May 19 jQuery
jquery分页插件pagination使用教程
Oct 23 #jQuery
使用jquery Ajax实现上传附件功能
Oct 23 #jQuery
jquery实现动态添加附件功能
Oct 23 #jQuery
jQuery.validate.js表单验证插件的使用代码详解
Oct 22 #jQuery
jQuery轻量级表单模型验证插件
Oct 15 #jQuery
jquery实现联想词搜索框和搜索结果分页的示例
Oct 10 #jQuery
jQuery 获取除某指定对象外的其他对象 ( :not() 与.not())
Oct 10 #jQuery
You might like
php中使用$_REQUEST需要注意的一个问题
2013/05/02 PHP
使用HMAC-SHA1签名方法详解
2013/06/26 PHP
php冒泡排序与快速排序实例详解
2015/12/07 PHP
yii2中添加验证码的实现方法
2016/01/09 PHP
php给数组赋值的实例方法
2019/09/26 PHP
Ajax执行顺序流程及回调问题分析
2012/12/10 Javascript
dwz 如何去掉ajaxloading具体代码
2013/05/22 Javascript
JS的location.href跳出框架打开新页面的方法
2014/09/04 Javascript
基于Css3和JQuery实现打字机效果
2015/08/11 Javascript
Google 地图API资料整理及详细介绍
2016/08/06 Javascript
JavaScript用二分法查找数据的实例代码
2017/06/17 Javascript
jQuery实现返回顶部按钮和scroll滚动功能[带动画效果]
2017/07/05 jQuery
基于nodejs实现微信支付功能
2017/12/20 NodeJs
javascript数组拍平方法总结
2018/01/20 Javascript
解决vue多个路由共用一个页面的问题
2018/03/12 Javascript
Python中的左斜杠、右斜杠(正斜杠和反斜杠)
2016/08/30 Python
Python基于OpenCV库Adaboost实现人脸识别功能详解
2018/08/25 Python
解决Numpy中sum函数求和结果维度的问题
2019/12/06 Python
Python sep参数使用方法详解
2020/02/12 Python
python下载卫星云图合成gif的方法示例
2020/02/18 Python
python新式类和经典类的区别实例分析
2020/03/23 Python
python实现经典排序算法的示例代码
2021/02/07 Python
解析浏览器的一些“滚动”行为鉴赏
2019/09/16 HTML / CSS
澳大利亚波西米亚风情网上商店:Czarina
2019/03/18 全球购物
HQhair美国/加拿大:英国化妆品、美容及美发产品商城
2019/04/15 全球购物
Farah官方网站:男士服装及配件
2019/11/01 全球购物
毕业生机械建模求职信
2013/10/14 职场文书
餐厅经理岗位职责范本
2014/02/17 职场文书
关于环保的演讲稿
2014/05/10 职场文书
讲文明懂礼貌演讲稿
2014/09/11 职场文书
合作合同协议书范本
2015/01/27 职场文书
常务副总经理岗位职责
2015/02/02 职场文书
2016国庆节67周年寄语
2015/12/07 职场文书
驾驶员安全责任协议书
2016/03/22 职场文书
分享提高 Python 代码的可读性的技巧
2022/03/03 Python
MySQL性能指标TPS+QPS+IOPS压测
2022/08/05 MySQL