• SSM 后端实现简单分页


    1. SQL(主要是limit语句,设置开始位置和每页大小)
      <!--获取所有,简单分页-->
      <select id="selectAllGuide" resultMap="BaseResultMap">
      select * from guide where del_flag = 0 LIMIT #{startLine},#{pageSize}
      </select>
    2. Mapper
      List<Guide> selectAllGuide(@Param("startLine") Integer startLine,@Param("pageSize") Integer pageSize);
    3. Service
      //简单分页功能
      //默认页码为第一页,默认每页大小10
      Integer defaultPageNum = 1;
      Integer defaultPageSize = 10;
      if (pageNum == null) {
      pageNum = defaultPageNum;
      }
      if(pageSize == null){
      pageSize = defaultPageSize;
      }
      Integer startLine = (pageNum - 1) * pageSize;
      guideList = guideMapper.selectAllGuide(startLine, pageSize);
    4. controller(传入页码和每页数量)
      public CommonReturnType getGuides(@Param("pageNum") Integer pageNum,@Param("pageSize")Integer pageSize, @RequestBody Guide guide) {
      String title = guide.getTitle();
      String documentId = guide.getDocumentId();
      List<Guide> guideList = guideService.getGuideList(pageNum,pageSize,title,documentId);
      return CommonReturnType.create(guideList,"查询成功");
      }
  • 相关阅读:
    1414 冰雕
    1475 建设国家(优先队列)
    Digit Division
    Sleep Buddies
    Reverse and Compare(DP)
    1536 不一样的猜数游戏
    Genealogical tree
    网站日志实时分析工具GoAccess使用
    CentOS下一键安装Openstack
    权重轮询调度算法(WeightedRound-RobinScheduling)-Java实现2
  • 原文地址:https://www.cnblogs.com/gslgb/p/12939890.html
Copyright © 2020-2023  润新知