SSM 框架下 使用 EasyUI 整合 PageHelper 实现分页

准备条件

1  .引入pageHelper 依赖包


           
            com.github.pagehelper
            pagehelper
            4.0.0
       

      
  

2.mybatis 主配置文件中加入如下:




   
    
   
       
       
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
       

   

    


3.spring 整合mybatis (加载mybatis 主配置文件)

    
        
        
        
                
                
                classpath*:/mybatis/mapper-*.xml
            

        

        
    

        

4.Controller 层实现方法
实例方法
//多条件查询的方法
    @RequestMapping("getEmpInfoList")
    @ResponseBody
    public HashMap searchConditionsEmp(
            String status,String orgId,
            String id,String loginName,
            @RequestParam("page") Integer pageNum,
            @RequestParam("rows") Integer rows
){
        
        //防止 参数值为 空字符串 "" mybatis 中无法识别的囧境遇
        Map map = new HashMap();
        map.put("status", "".equals(status)?null:status);
        map.put("orgId", "".equals(orgId)?null:orgId);
        map.put("id", "".equals(id)?null:id);
        map.put("loginName", "".equals(loginName)?null:loginName);
        //分页所需的数据
        map.put("rows", rows);
        map.put("pageNum", pageNum);
            

        //将 当前页码   每页显示条数 放入 到pageHelper 中
        PageHelper.startPage(pageNum, rows);
        
        //查询所记录的方法(此句 在mybaits 查询语句中不要在加入 limt pageHelper 会自动注入)
        List empInfoList = employeeInfoService.getEmpInfoList(map);
        
        //调用需要分页处理的 执行方法(会在SQL 语句中自动加入 limit )
        PageInfo pageInfo = new PageInfo(empInfoList);
        
        //获取总记录数
        long total = pageInfo.getTotal(); 
        

        //封装获取到的分页数据 封装成分页插件所需要的格式
        HashMap jsonMap = new HashMap();
        jsonMap.put("total", total);
        jsonMap.put("rows", empInfoList);

        
        
        return jsonMap;
        
    }

5.前端easyui整合  分页  

   


        class="easyui-datagrid" style="width:100%;height:250px" 
                pagination='true' rownumbers='true'(加入两个属性 datagrid 会自动加入分页插件)
            data-options="url:'getEmpInfoList.do',fitColumns:true,singleSelect:true">   
               
                   
                    
                    
                    
                       
                    
                       
                       
                    
                       
                       
                   
               
        
员工状态账号姓名性别入职时间岗位机构录入时间修改时间

   


 

你可能感兴趣的:(Easyui分页,PageHelper,Easyui分页,SSM,pagination,datagrid)