jquery.pagination.js分頁(yè)使用教程
簡(jiǎn)單介紹一下在動(dòng)態(tài)網(wǎng)頁(yè)里面的jquery.pagination.js分頁(yè)的使用,具體內(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)簽,獲取控制器傳過(guò)來(lái)的值
<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>
<!--分頁(yè)顯示-->
<div id="Pagination"></div>
js
var limit=<%=request.getAttribute("limit")%>;//每頁(yè)顯示多少 條數(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, // 每頁(yè)顯示多少條記錄
current_page: Math.ceil(index/limit), //當(dāng)前頁(yè)
num_display_entries:4, // 分頁(yè)顯示的條目數(shù)
next_text:"下一頁(yè)",
prev_text:"上一頁(yè)",
num_edge_entries:2, // 連接分頁(yè)主體,顯示的條目數(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", "沒(méi)有該商品");
}
//數(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)文章
簡(jiǎn)潔實(shí)用的BootStrap jQuery手風(fēng)琴插件
這篇文章主要介紹了簡(jiǎn)潔實(shí)用的BootStrap jQuery手風(fēng)琴插件知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08
jQuery實(shí)現(xiàn)拼圖小游戲(實(shí)例講解)
下面小編就為大家?guī)?lái)一篇jQuery實(shí)現(xiàn)拼圖小游戲(實(shí)例講解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-07-07
jquery在項(xiàng)目中做復(fù)選框時(shí)遇到的一些問(wèn)題筆記
在實(shí)踐中還是遇到了很多的問(wèn)題,注意在input的checkbox中,用普通的attr屬性來(lái)判斷是不可以的,因?yàn)閏hecked的值是checked,因此做個(gè)筆記2013-11-11
jQuery插件原來(lái)如此簡(jiǎn)單 jQuery插件的機(jī)制及實(shí)戰(zhàn)
這種插件是將對(duì)象方法封裝起來(lái),用于對(duì)通過(guò)選擇器獲取的jQuery對(duì)象進(jìn)行操作,是最常見(jiàn)的一種插件2012-02-02
DIV隨滾動(dòng)條滾動(dòng)而滾動(dòng)的實(shí)現(xiàn)代碼【推薦】
下面小編就為大家?guī)?lái)一篇DIV隨滾動(dòng)條滾動(dòng)而滾動(dòng)實(shí)現(xiàn)代碼【推薦】。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-04-04
jQuery購(gòu)物車插件jsorder用法(支持后臺(tái)處理程序直接轉(zhuǎn)換成DataTable處理)
這篇文章主要介紹了jQuery購(gòu)物車插件jsorder用法,結(jié)合實(shí)例形式分析了購(gòu)物車jsorder插件基于ajax與后臺(tái)交互的相關(guān)技巧,需要的朋友可以參考下2016-06-06

