关于layui的分页插件的使用
来源:互联网 发布:深圳美生创谷淘宝地址 编辑:程序博客网 时间:2024/06/06 01:41
前台html,用于显示分页按钮:
<div style="text-align: center" id="page"> </div>
前台js:
layui.use(['laypage'], function(){// 页面引用 var currentPage='${pageInfo.currentPage}'; //当前页 var pageNum='${pageInfo.pageNum}'; //总页数 var totalCount="${pageInfo.totalCount}"; //查询总条数 var pageSize=6; //每页条数 //分页laypage({ cont: 'page' ,pages: pageNum ,groups: 5 ,curr:currentPage ,first: "首页" ,last: "尾页" ,jump: function(obj, first){ if(!first){ window.location.href="${pageContext.request.contextPath}/post/${postInfo.post.postid}/"+obj.curr+".html"; } }});//模拟渲染var render = function(data, curr){ var arr = [] ,thisData = data.concat().splice(curr*nums-nums, nums); layui.each(thisData, function(index, item){ arr.push('<li>'+ item +'</li>'); }); return arr.join('');}; }); });
后台处理的controller:
@RequestMapping("/post/{postId}/{currentPage}")public String getAnswer(@PathVariable long postId, @PathVariable int currentPage,Model model) {if(currentPage==1) { return "redirect:/post/"+postId+".html";}FlyPageInfo pageInfo=answerService.getPostAnswer(postId, currentPage, 6);PostCatalog catalog=postService.getPostCatalog(postId);model.addAttribute("postInfo", catalog);model.addAttribute("pageInfo", pageInfo);return "jie/detail";}
后台serviceImpl:
//分页 帖子的回答public FlyPageInfo getPostAnswer(long postid,int page, int rows) {FlyAnswerExample example=new FlyAnswerExample();example.setOrderByClause("created asc");example.createCriteria().andPostidEqualTo(postid);PageHelper.startPage(page, rows);List<FlyAnswer> answerList=answerMapper.selectByExampleWithBLOBs(example);for (FlyAnswer flyAnswer : answerList) {try {flyAnswer.setAnstime(DateUtil.getDate(flyAnswer.getCreated()));} catch (ParseException e) {e.printStackTrace();}}PageInfo<FlyAnswer> pageInfo=new PageInfo<FlyAnswer>(answerList);long total = pageInfo.getTotal();FlyPageInfo flyPageInfo=new FlyPageInfo(page,TotalUtil.gePagetTotal(total, rows), total, answerList);return flyPageInfo;}
阅读全文
1 0
- 关于layui的分页插件的使用
- 分页控件layui的使用
- LayUI自定义分页插件,仿EasyUI的DataGrid
- 关于layui数据表格的分页操作的学习笔记。
- 关于layer以及layui的使用心得
- 漂亮的layui 分页展示
- layui+jquery支持IE8的表格分页
- nodejs+layui+laytpl实现分页的例子
- 分页插件的使用
- layui--一个不错的页面插件框架
- 关于Spring+mybatis+PageHelper分页插件PageHelper的使用策略
- Bootstrap 分页插件的使用
- Bootstrap 分页插件的使用
- kaminari分页插件的使用
- mybatis分页插件的使用
- pageHelper分页插件的使用
- PageHelper分页插件的使用
- pageHelper分页插件的使用
- CSR8670蓝牙模块BQB认证经验总结
- JS原型对象和原型链
- 百度前端学院_任务二零基础HTML及CSS编码
- 2017.07.08【NOIP提高组】模拟赛B组
- Efficient Diffusion on Region Manifolds Recovering Small Objects with Compact CNN Representations
- 关于layui的分页插件的使用
- windows下Mysql5.7.18修改初始密码
- python键盘输入五个数字,判断是否是回文数
- 【bzoj1905】捉迷藏(线段树)
- java 8——Lambda表达式
- 十二、JVM如何利用工具来监控调优前后的性能变化。
- 深入理解Linux内核 第一章笔记
- Jquery ajax异步传值的两个json实用的写法,
- ZJU1024-Calendar Game(模拟)