jquery.pagination.js分頁使用教程
簡(jiǎn)單介紹一下在動(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";
}
效果圖

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
jQuery實(shí)現(xiàn)鼠標(biāo)單擊網(wǎng)頁文字后在文本框顯示的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)鼠標(biāo)單擊網(wǎng)頁文字后在文本框顯示的方法,可實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊上方文字即可在下方勾選處文本框顯示對(duì)應(yīng)文字的效果,涉及jQuery鼠標(biāo)事件及鏈?zhǔn)讲僮鞯南嚓P(guān)技巧,需要的朋友可以參考下2015-05-05
Jquery節(jié)點(diǎn)遍歷next與nextAll方法使用示例
next()方法用于獲取“節(jié)點(diǎn)之后”挨著它的第一個(gè)“同類同輩”元素。nextAll()方法用于獲取“節(jié)點(diǎn)之后”所有的元素2014-07-07
jQuery學(xué)習(xí)之DOM節(jié)點(diǎn)的插入方法總結(jié)
這篇文章主要給大家介紹了jQuery中DOM節(jié)點(diǎn)的插入方法,文章總結(jié)的很全面,相信對(duì)大家具有一定的參考價(jià)值,需要的朋友們一起來看看吧。2017-01-01
JQuery實(shí)現(xiàn)Ajax加載圖片的方法
這篇文章主要介紹了JQuery實(shí)現(xiàn)Ajax加載圖片的方法,涉及jQuery基于緩存獲取圖片的技巧,需要的朋友可以參考下2015-12-12
jQuery Ajax提交表單查詢獲得數(shù)據(jù)實(shí)例代碼
用戶輸入一個(gè)表單,輸入準(zhǔn)考證和驗(yàn)證碼,驗(yàn)證用戶是否輸入表單,點(diǎn)擊查詢提交,然后從服務(wù)器得到返回的數(shù)據(jù)并顯示出來2012-09-09
jQuery中Ajax全局事件引用方式及各個(gè)事件(全局/局部)執(zhí)行順序
這篇文章主要介紹了jQuery中Ajax全局事件引用方式及各個(gè)事件(全局/局部)執(zhí)行順序的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起學(xué)習(xí)吧2016-06-06

