• pagehelper分页操作


    一、后端
    二、前端

    一、后端

    1、导入依赖

    <!-- pagehelper分页 -->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
                <version>1.2.5</version>
            </dependency>
    

    2、pojo层

    3、dao层

    mapper

    List<FP2_T_Schedulejoblog> selectfp2Tschedulejoblog(Integer pageNum, Integer pageSize);
    

    mapper.xml

    <select id="selectfp2TscheduleJobLog" resultMap="FP2_T_SchedulejoblogMap">
        SELECT *
        FROM FP2_T_SCHEDULEJOBLOG order by LOG_ID desc
      </select>
    

    4、service层

    service

    PageInfo<FP2_T_Schedulejoblog> selectfp2Tschedulejoblog(Integer pageNum, Integer pageSize);
    

    serviceImpl

    @Override
        public PageInfo<FP2_T_Schedulejoblog> selectfp2Tschedulejoblog(Integer pageNum, Integer pageSize) {
            PageHelper.startPage(pageNum , pageSize);
            List<FP2_T_Schedulejoblog> list = fP2_T_SchedulejoblogMapper.selectfp2Tschedulejoblog(pageNum,pageSize);
            PageInfo<FP2_T_Schedulejoblog> personPageInfo = new PageInfo<>(list);
            //将结果存入map进行传送
            return personPageInfo;
        }
    

    5、controller层

    @GetMapping("/pageselectJobLog")
        public String pageselectJobLog(Model model,@RequestParam(required=true,value="pageNum",defaultValue="0") Integer pageNum,
                                    @RequestParam(required=true,value="pageSize",defaultValue="5") Integer pageSize) {
            PageInfo<FP2_T_Schedulejoblog> jobss  = fP2_T_SchedulejoblogServiceImpl.selectfp2Tschedulejoblog(pageNum,pageSize);
            /*model.addAttribute("rolename",record.getAppName());*/
            model.addAttribute("jobslog", jobss.getList() );
            //当前页
            model.addAttribute("pageNum",jobss.getPageNum());
            //每页条数
            model.addAttribute("pageSize",jobss.getPageSize());
            //总数据量
            model.addAttribute("total",jobss.getTotal());
            //System.out.println(jobss.size());
            return "log_list";
        }
    

    二、前端

    1、导入layUI模板

    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css" />
    <script src="https://www.layuicdn.com/layui/layui.js"></script>  
    

    2、导航栏

    (Layui)或者

    <div class="pagination pagination-centered" id="pagediv">
                        </div>
    

    bootstrap)

     <div class="box">
                            <div id="pagediv" class="page center">
                            </div>
                        </div>
    

    或者

    3、java script

    <script th:inline="javascript">
        /*<![CDATA[*/
        layui.use(['laypage', 'layer'], function(){
            var laypage = layui.laypage
                ,layer=layui.layer;
            laypage.render({
                elem: 'pagediv', //容器。值支持id名、原生dom对象,jquery对象。【如该容器为】:<div
                count: /*[[${total}]]*/ 1, //数据总数
                skip:true,
                limit: /*[[${pageSize}]]*/ 1,
                groups:5,
                first:'首页',
                curr: /*[[${pageNum}]]*/ 1, //获取起始页
    
                jump: function(obj, first){ //触发分页后的回调
                    if(!first){ //点击跳页触发函数自身,并传递当前页:obj.curr
                        self.location.href=("/joblog/pageselectJobLog?pageNum="+obj.curr);
                        //list(obj.curr);
                    }
    
                }
            });
        });
        /*]]>*/
    </script>
    
  • 相关阅读:
    Unity3D命令行Build
    关于Unity3D的协程(Coroutine)
    牛腩购物34:支付宝的集成和使用(web网站和web应用程序一眼判断的区别),支付宝即时到账
    linqpad 的下载使用
    linq 的延时执行和即时执行
    冒泡排序
    c# 的继承,继承类实例化的时候,会先调用基类的构造函数,然后再调用自己的构造函数,base 的用法,有override和没有override的区别
    zoj1002 Fire Net
    zjut1675 I like DPS!!!
    zjut1673搭数字II
  • 原文地址:https://www.cnblogs.com/zhuchengbo/p/12791798.html
Copyright © 2020-2023  润新知