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 >商品显⽰</th>
</tr>
<tr align="center" bgcolor="#799AE1" >
<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="${dsId}"></c:out></td>
<td align=center id="goodsType" class=txlrow><c:out
value="${dsType}"></c:out></td>
<td align=center id="goodsName" class=txlrow><c:out
value="${dsName}"></c:out></td>
<td align=center id="goodsContent" class=txlrow><c:out
value="${dsContent}"></c:out></td>
<td align=center id="goodsPrice" class=txlrow><c:out
value="${dsPrice}"></c:out></td>
<td align=center id="goodsSell" class=txlrow><c:out
value="${dsSell}"></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=<%=Attribute("limit")%>;//每页显⽰多少条数据
var count=<%=Attribute("count")%>//共多少条数据
var index=<%=Attribute("index")%>;//当前记录数
$(function(){
$("#Pagination").pagination(count, {
items_per_page:limit, // 每页显⽰多少条记录
current_page: il(index/limit), //当前页
num_display_entries:4, // 分页显⽰的条⽬数
next_text:"下⼀页",
prev_text:"上⼀页",
num_edge_entries:2, // 连接分页主体,显⽰的条⽬数
callback:handlePaginationClick
});
});
jquery学习在线教程
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";
}
效果图
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。