zoukankan      html  css  js  c++  java
  • mybatis分页插件PageHelper简单应用

    --添加依赖

    <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
    <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.1.10</version>
    </dependency>

    <!--boot框架可引入该依赖 https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
    <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.10</version>
    </dependency>

    --springboot配置(.yml)

    #pagehelper
    pagehelper:
        helperDialect: mysql
        #设置超过最大页数不再返回数据
        reasonable: false
        supportMethodsArguments: true
        params: count=countSql
        returnPageInfo: check

    --简单使用(对于线程安全问题可以参考官网,注意对于大数据量,会用性能瓶颈)

    int pageNum = Integer.parseInt(request.getParameter("pageNum"));
    int pageSize = Integer.parseInt(request.getParameter("pageSize"));
    PageHelper.startPage(pageNum,pageSize);
    List<Map<String,Object>> list = getMarkersiteListNew(paramMap);
    PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(list);
    Map<String,Object> listMap = new HashMap<>();
    listMap.put("list",list);
    listMap.put("pageNum",pageNum);
    listMap.put("pageSize",pageSize/*list.size()*/);
    listMap.put("total",pageInfo.getTotal());

  • 相关阅读:
    动态二维码
    二维码
    购物车
    logback学习与配置使用
    UML类图几种关系的总结
    java.lang.Excetion,java.lang.RuntimeException,java.lang.Error有什么区别?
    Java编程最差实践
    Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
    从 Java 代码到 Java 堆
    Project configuration is not up-to-date with pom.xml
  • 原文地址:https://www.cnblogs.com/sung1024/p/11178691.html
Copyright © 2011-2022 走看看