简单介绍一下在动态网页里面的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="/UploadFiles/2021-04-02/jquery-1.11.3.js">表格,用的是c标签,获取控制器传过来的值
<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>商品规格</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="${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")%>;//每页显示多少 条数据 var count=<%=request.getAttribute("count")%>//共多少条数据 var index=<%=request.getAttribute("index")%>;//当前记录数 $(function(){ $("#Pagination").pagination(count, { items_per_page:limit, // 每页显示多少条记录 current_page: Math.ceil(index/limit), //当前页 num_display_entries:4, // 分页显示的条目数 next_text:"下一页", prev_text:"上一页", num_edge_entries:2, // 连接分页主体,显示的条目数 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"; //从服务器获取数据 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"; }效果图
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 王菲.2006《菲常好听》引进版[低速原抓WAV+CUE]
- 《三日危情独家的记忆》女角色介绍
- 《天国拯救》拉泰比武大会攻略
- 任天堂推出《马里奥惊奇》NS捆绑包 10月24日发售
- 《孤岛惊魂》能否逆转育碧颓势?曝系列新作正招兵买马
- 天命人呼叫战术轰炸!玩家自制《黑神话:悟空》轰炸机Mod
- 群星.1992-滚石九大天王·十二出好戏【滚石】【WAV+CUE】
- 群星.1994-新滚石九大天王之年度大丫滚石】【WAV+CUE】
- 坣娜.1998-别恋【非常喜】【WAV+CUE】
- 《草原经典 最炫草原风 2CD》[WAV/分轨][980MB]
- 《不烧不选 经典国语极品珍藏》[WAV/分轨][500MB]
- 《绝对主打 流行原创金曲 2CD》[WAV分轨][1.1GB]
- 《赛博朋克2077》更新上线:支持AMD FSR3
- 《塞尔达传说:智慧的再现》提前半个月偷跑,引发玩家担忧
- 战锤40K星际战士2全职业介绍|全职业技能效果一览