jquery.pagination.js分页使用教程

 更新时间:2018年10月23日 14:11:04   作者:小虎哥的技术博客  
这篇文章主要为大家详细介绍了jquery.pagination.js分页使用教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

简单介绍一下在动态网页里面的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 ajax属性async(同步异步)示例

    jquery ajax属性async(同步异步)示例

    在jquery的ajax中如果我们希望实现同步或者异步我们可以直接设置async发生为真或假即可true false,下面举几个jquery ajax同步和异步实例
    2013-11-11
  • jQuery实现鼠标单击网页文字后在文本框显示的方法

    jQuery实现鼠标单击网页文字后在文本框显示的方法

    这篇文章主要介绍了jQuery实现鼠标单击网页文字后在文本框显示的方法,可实现鼠标点击上方文字即可在下方勾选处文本框显示对应文字的效果,涉及jQuery鼠标事件及链式操作的相关技巧,需要的朋友可以参考下
    2015-05-05
  • jquery判断浏览器类型的代码

    jquery判断浏览器类型的代码

    用jquery来判断浏览器类型,如果只是仅仅为了判断浏览器的类型而使用该方法,那么不建议使用,只是在你已经使用了jquery才建议使用,因为没必要因为这么小的一个功能就加载那么大的类库吧
    2012-11-11
  • Jquery节点遍历next与nextAll方法使用示例

    Jquery节点遍历next与nextAll方法使用示例

    next()方法用于获取“节点之后”挨着它的第一个“同类同辈”元素。nextAll()方法用于获取“节点之后”所有的元素
    2014-07-07
  • jQuery学习之DOM节点的插入方法总结

    jQuery学习之DOM节点的插入方法总结

    这篇文章主要给大家介绍了jQuery中DOM节点的插入方法,文章总结的很全面,相信对大家具有一定的参考价值,需要的朋友们一起来看看吧。
    2017-01-01
  • JQuery实现Ajax加载图片的方法

    JQuery实现Ajax加载图片的方法

    这篇文章主要介绍了JQuery实现Ajax加载图片的方法,涉及jQuery基于缓存获取图片的技巧,需要的朋友可以参考下
    2015-12-12
  • jQuery随机密码生成的方法

    jQuery随机密码生成的方法

    这篇文章主要介绍了jQuery随机密码生成的方法,实例分析了jQuery操作随机数的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-03-03
  • jQuery Ajax提交表单查询获得数据实例代码

    jQuery Ajax提交表单查询获得数据实例代码

    用户输入一个表单,输入准考证和验证码,验证用户是否输入表单,点击查询提交,然后从服务器得到返回的数据并显示出来
    2012-09-09
  • jQuery中Ajax全局事件引用方式及各个事件(全局/局部)执行顺序

    jQuery中Ajax全局事件引用方式及各个事件(全局/局部)执行顺序

    这篇文章主要介绍了jQuery中Ajax全局事件引用方式及各个事件(全局/局部)执行顺序的相关资料,非常不错,具有参考借鉴价值,感兴趣的朋友一起学习吧
    2016-06-06
  • 浅析jQuery中使用$所引发的问题

    浅析jQuery中使用$所引发的问题

    这篇文章主要介绍了浅析jQuery中使用$所引发的问题的相关资料,f非常不错具有参考借鉴价值,需要的朋友可以参考下
    2016-05-05

最新评论