zoukankan      html  css  js  c++  java
  • mybatis-- 分页插件(pageHelper)

    pageHelper插件的优点和弊端

    1.优点:快速,方便,简洁的查询结构,后端只需要提供一个select查询返回数据,插件自动给你的分页

    java代码框架

    @GetMapping("/ceshi")
    public BaseResponse ceshi(Model model, @RequestParam(required = false, defaultValue = "1", value = "pn") Integer pn, String 请求参数(可有可无,限情况而定)) {
    BaseResponse response = new BaseResponse();
    try {
    PageHelper.startPage(pn, 6); //pn--页数默认为1,定值---每页的数量 //注意:改分页后必须跟一条sql,是根据这条sql limit 0,6,
    List<实体> date = service.select(请求参数);
    PageInfo<实体> p = new PageInfo<>(date);
    model.addAttribute("deptList", date);
    model.addAttribute("page", p);
    response.setData(p);
    response.setSuccess(true);
    return response;
    } catch (Exception e) {
    response.setErrorMsg(ErrorCode.SYSTEM_ERROR.getDesc());
    }
    return response;
    }

    2.弊端:

    PageHelper.startPage(pn, 6);
    只会针对那一条sql进行limit ,第二条及其之后的sql不会limit
    结论:针对弊端可将多条sql进行一个整合,整合为一条sql,
    建议:
    1.可能会用到sql函数:(select * from table1) union all (select * from table2) 注意:前后sql结构必须一致
      2.select *,count(distincf 条件字段) from table group by 条件字段 出现*,count(字段) 后面必须跟grounp by 字段
    根据指定条件对100+条数据的其中几条数据进行字段筛选
    
    
    
  • 相关阅读:
    python模块win32com中的early-bind与lazy-bind(以Autocad为例)
    Beautiful code and beautiful life
    PyPI 使用的国内源
    JavaScript在SublimeText中的配置
    Python中的模块包
    FTP 服务器在WIN10上的搭建及服务端下载文件实例
    Oracle ASM磁盘组兼容性
    oracle ADVM
    053-28
    053-27
  • 原文地址:https://www.cnblogs.com/Darkqueen/p/11211734.html
Copyright © 2011-2022 走看看