首页 > 其他分享 >springboot分页插件的问题

springboot分页插件的问题

时间:2023-04-27 17:22:41浏览次数:31  
标签:map 插件 springboot get int 查询 pagehelper 分页

1:maven依赖的问题 此类原因是与pom.xml文件中引入的分页依赖有关,由于springboot本身集成pagerhelper的分页插件,只需要引入如下依赖即可

<!-- spring-boot mybatis pagehelper --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.10</version> </dependency> 如引入的为如下依赖,需要添加Bean注入(如何添加请自行百度)

<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.1.10</version> </dependency> 2:执行PageHelper.startPage(int pageNum, int pageSize)之后没有紧跟分页查询,而是先执行了其他查询 如下初始化分页器后,应该紧跟mybatis的分页查询语句,方法中如有其他查询需求,需要在其他查询完成后,再执行PageHelper.startPage(int pageNum, int pageSize)方法

public PageInfo<R> page(Map<String, ? extends Object> map) {
//获取第1页,10条内容,默认查询总数count
  PageHelper.startPage(Integer.parseInt(map.get("pageNum").toString()), Integer.parseInt(map.get("pageSize").toString()));
  String sql = String.format("%s%s",sqlMapping , map.get("mapping")==null?"getPageObjList" : map.get("mapping")) ;
List<R> l = sqlSessionTemplate.selectList(sql , map);
return new PageInfo<R>(l);
}

3:没有配置mybatis的分页拦截器(也是我遇到的问题) 当拦截器没有配置的时候,每次进行List查询都会返回全部结果数据,此时需要在启动类中注入拦截器类

@Bean
public Interceptor[] plugins() {
return new Interceptor[]{new PageInterceptor()};
}

或者在MyBatis的配置文件mybatis-config.xml中添加如下代码

<configuration> <plugins> <plugin interceptor="com.github.pagehelper.PageInterceptor"/> </plugins> </configuration>

标签:map,插件,springboot,get,int,查询,pagehelper,分页
From: https://www.cnblogs.com/xiaohanxqh/p/17359521.html

相关文章

  • PS磨皮滤镜降噪插件套装Imagenomic Professional Plugin Suite
    ImagenomicProfessionalPluginSuite插件下载ImagenomicProfessionalPluginSuiteforMac是一款适用于苹果操作系统的专业级插件套装,包括了Noiseware、Portraiture和Realgrain三个插件。Noiseware可以快速去除图像中的噪点,提高图像的清晰度和质量。Portraiture是一款人像修......
  • SpringBoot配置日志文件定期切割
    下面是我的配置:创建logback-spring.xml写入下面的配置<?xmlversion="1.0"encoding="UTF-8"?><configurationdebug="false"><!--定义日志文件的存储地址勿在LogBack的配置中使用相对路径--><propertyname="LOG_HOME"value=&quo......
  • wp常用插件
    好用插件: 1.备份迁移插件wpvivid2. ElementorElementor网站构建器拥有一切:拖放页面构建器,像素完美设计,移动响应式编辑等等3. WPSuperCacheWPSuperCache4.浮动插件SimpleFloatingMenu5.  ......
  • UNRAID6.11.1开心版下载及使用说明(集成中文插件)
    众所周知,所谓开心版就是已经解除限制功能,可正常开心使用。申明:此版本用于个人测试研究使用,如用于生产环境请购买官方正版,支持正版。部份资源转载于网络,请自行测试研究,下载测试后自行删除,如因软件版权及功能引起的任何问题自用户自行承担。该版本集成了常用插件,默认简体中文界面,......
  • publish over ssh插件的使用。
    配置1.先安装publishoverssh插件,然后重新启动jenkins。2.安装后,给服务器起一个别名、配置ip,用户名、端口号、密码。连接测试,提示:success就代表成功了。如果提示密钥无效,而自己配置的都没有问题,可以选择把安装了jenkins的服务器重新一下,或者用别的服务器安装jenkins在试一下......
  • 内存分页
    publicstatic<T>PageResult<T>newPage(List<T>content,IntegerpageNum,Integerpages){inttotal=content.size();intoffset=(pageNum-1)*pages;if(offset>total){returnnewPageResult<T>(null,pag......
  • springboot入门时,发现Java版本与Spring boot版本无法对应导致错误的问题解决
    <?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/......
  • SpringBoot SpringSecurity 介绍(基于内存的验证)
    SpringBoot集成SpringSecurity+MySQL+JWT附源码,废话不多直接盘SpringBoot已经为用户采用默认配置,只需要引入pom依赖就能快速启动SpringSecurity。目的:验证请求用户的身份,提供安全访问优势:基于Spring,配置方便,减少大量代码内置访问控制方法permitAll()表示所匹配的......
  • SpringBoot 集成 SpringSecurity + MySQL + JWT 附源码,废话不多直接盘
    SpringBoot集成SpringSecurity+MySQL+JWT无太多理论,直接盘一般用于Web管理系统可以先看SpringBootSpringSecurity基于内存的使用介绍本文介绍如何整合SpringSecurity+MySQL+JWT数据结构数据库脚本:https://gitee.com/VipSoft/VipBoot/blob/develop/vipsoft-sec......
  • SpringBoot配置MongoDb
    MongoDb建表:MongoDB不需要建表,直接插入数据就会建表。日期用ISODate()转换。db.getCollection("mongoDbTest").insert({userId:"dxcefg",status:1,price:1.23,updateTime:ISODate("2022-02-13T07:06:25.371Z")})添加maven依赖:<dependency>......