jquery.pagination.js分頁使用教程
更新時間:2018年10月23日 14:11:04 作者:小虎哥的技術(shù)博客
這篇文章主要為大家詳細(xì)介紹了jquery.pagination.js分頁使用教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
簡單介紹一下在動態(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>商品編號</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)價</td>
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>當(dāng)前售價</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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
簡潔實用的BootStrap jQuery手風(fēng)琴插件
這篇文章主要介紹了簡潔實用的BootStrap jQuery手風(fēng)琴插件知識,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-08-08
jQuery插件原來如此簡單 jQuery插件的機(jī)制及實戰(zhàn)
這種插件是將對象方法封裝起來,用于對通過選擇器獲取的jQuery對象進(jìn)行操作,是最常見的一種插件2012-02-02
jQuery購物車插件jsorder用法(支持后臺處理程序直接轉(zhuǎn)換成DataTable處理)
這篇文章主要介紹了jQuery購物車插件jsorder用法,結(jié)合實例形式分析了購物車jsorder插件基于ajax與后臺交互的相關(guān)技巧,需要的朋友可以參考下2016-06-06

