jquery.pagination.js分頁使用教程
簡單介紹一下在動(dòng)態(tài)網(wǎng)頁里面的jquery.pagination.js分頁的使用,具體內(nèi)容如下
添加下載的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標(biāo)簽,獲取控制器傳過來的值
<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>商品編號(hào)</td> <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品大類</td> <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品名稱</td> <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品規(guī)格</td> <td width="10%" align="center" class=txlHeaderBackgroundAlternate>加權(quán)進(jìn)價(jià)</td> <td width="10%" align="center" class=txlHeaderBackgroundAlternate>當(dāng)前售價(jià)</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")%>;//每頁顯示多少 條數(shù)據(jù) var count=<%=request.getAttribute("count")%>//共多少條數(shù)據(jù) var index=<%=request.getAttribute("index")%>;//當(dāng)前記錄數(shù) $(function(){ $("#Pagination").pagination(count, { items_per_page:limit, // 每頁顯示多少條記錄 current_page: Math.ceil(index/limit), //當(dāng)前頁 num_display_entries:4, // 分頁顯示的條目數(shù) next_text:"下一頁", prev_text:"上一頁", num_edge_entries:2, // 連接分頁主體,顯示的條目數(shù) 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"; //從服務(wù)器獲取數(shù)據(jù) List<Goods> goodsS = goodsService.selectGoods(goods, Integer.parseInt(index), PageParam.limit); if (goodsS != null) { model.addAttribute("goodsS", goodsS); } else { model.addAttribute("resultMsg", "沒有該商品"); } //數(shù)據(jù)總條數(shù) int count = goodsService.selectAllCount(goods); model.addAttribute("index", index); model.addAttribute("count", count); model.addAttribute("limit", PageParam.limit); System.out.println("第" + index + "數(shù)據(jù)開始顯示" + goodsS.size() + "條記錄"); return "goodsManager/showGoods"; }
效果圖
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
簡潔實(shí)用的BootStrap jQuery手風(fēng)琴插件
這篇文章主要介紹了簡潔實(shí)用的BootStrap jQuery手風(fēng)琴插件知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08jQuery實(shí)現(xiàn)拼圖小游戲(實(shí)例講解)
下面小編就為大家?guī)硪黄猨Query實(shí)現(xiàn)拼圖小游戲(實(shí)例講解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07jquery在項(xiàng)目中做復(fù)選框時(shí)遇到的一些問題筆記
在實(shí)踐中還是遇到了很多的問題,注意在input的checkbox中,用普通的attr屬性來判斷是不可以的,因?yàn)閏hecked的值是checked,因此做個(gè)筆記2013-11-11jQuery插件原來如此簡單 jQuery插件的機(jī)制及實(shí)戰(zhàn)
這種插件是將對(duì)象方法封裝起來,用于對(duì)通過選擇器獲取的jQuery對(duì)象進(jìn)行操作,是最常見的一種插件2012-02-02DIV隨滾動(dòng)條滾動(dòng)而滾動(dòng)的實(shí)現(xiàn)代碼【推薦】
下面小編就為大家?guī)硪黄狣IV隨滾動(dòng)條滾動(dòng)而滾動(dòng)實(shí)現(xiàn)代碼【推薦】。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-04-04jQuery購物車插件jsorder用法(支持后臺(tái)處理程序直接轉(zhuǎn)換成DataTable處理)
這篇文章主要介紹了jQuery購物車插件jsorder用法,結(jié)合實(shí)例形式分析了購物車jsorder插件基于ajax與后臺(tái)交互的相關(guān)技巧,需要的朋友可以參考下2016-06-06