wordpress详细安装教程,seo排名关键词搜索结果,网站图片切换代码,网站建设维护单位文章目录 Mybatis Plus自带分页和PageHelper有什么区别#xff1f;Mybatis Plus整合PageHelper分页 springboot自定义拦截器获取分页参数spring boot下配置mybatis-plus分页插件单表分页查询自定义sql分页查询PageHelper 参考 Mybatis Plus自带分页和PageHelper有什么区别Mybatis Plus整合PageHelper分页 springboot自定义拦截器获取分页参数spring boot下配置mybatis-plus分页插件单表分页查询自定义sql分页查询PageHelper 参考 Mybatis Plus自带分页和PageHelper有什么区别
网上描述 Mapper Plus自带分页PaginationInterceptor对象虽然说目前没有什么问题并且使用简单但是个人感觉有个弊端目前个人使用中想要用Mapper Plus自带的分页功能的话需要在mapper对象中传入一个Page对象才可以实现分页这样耦合度是不是太高了一点从web到service到mapper这个Page对象一直都在传入这样的使用让人感觉有点麻烦~
Mybatis Plus整合PageHelper分页
Mybatis Plus整合PageHelper分页 参考URL: https://blog.csdn.net/m0_37701381/article/details/100719280 SpringBoot2.1MybatisPlusPagehelper框架整合其中与Dubbo整合时分页失效的疑问与解决 参考UIRL: https://blog.csdn.net/lstcui/article/details/89068918
springboot自定义拦截器获取分页参数
ThreadLocal Pager 分页的一种解决方案 参考URL: https://blog.csdn.net/cmdsmith/article/details/66969728
spring boot下配置mybatis-plus分页插件
springBoot 使用 mybatis-plus 插件 实现分页 https://blog.csdn.net/sinat_34338162/article/details/83543994?depth_1-utm_sourcedistribute.pc_relevant.none-taskutm_sourcedistribute.pc_relevant.none-task
需要写一个分页的配置类分页功能才能生效
/*** //Spring boot方式* Description: MybatisPlus配置类*/
Configuration
public class MyBatisPlusConfig {/*** 分页插件* return*/Beanpublic PaginationInterceptor paginationInterceptor() {return new PaginationInterceptor();}
}单表分页查询
如果只是单表那么分页查询就容易的多了。 这里的ModelAttribute注解可以将前端传过来的current和size字段映射到Page对象中。 /*** param page 查询一般传入参数为current和size, 例如/listPage?current1size5,* return 返回分页数据*/RequestMapping(value /page, method RequestMethod.GET)public ResponseObjPageT listPage(ModelAttribute PageT page, ModelAttribute T model) {PageT pageList service.selectPage(page, new EntityWrapper(model));for (T eachObj : pageList.getRecords()) {queryFilter(eachObj);}return new ResponseObj(pageList, RetCode.SUCCESS);} RestControllerRequestMapping(/student)public class StudentController {AutowiredIStudentService studentService;RequestMapping(value /findAll,method RequestMethod.POST)public Object findAll(HttpServletRequest request){//获取前台发送过来的数据Integer pageNo Integer.valueOf(request.getParameter(pageNo));Integer pageSize Integer.valueOf(request.getParameter(pageSize));IPageStudent page new Page(pageNo, pageSize);QueryWrapperStudent wrapper new QueryWrapper();Student student new Student();student.setId(1);wrapper.setEntity(student);return studentService.page(page,wrapper);}}总结 整体思路很简单需要2个参数一个是 IPage page实例传入pageNo、pageSize 一个是QueryWrapper wrapper实例。 使用时把page传入会自动在sql语句后面添加limit。 自定义sql分页查询
有时候查询的数据难免会出现多表连接查询或者是一些复杂的sql语句但是这些语句也是需要支持分页查询的。
先定义查询接口第一个参数要是分页的参数。
步骤一在mapper文件中编写对应的分页查询接口。
步骤二在xml中编写对应的sql语句小编这里演示的 “${ew.customSqlSegment}”这个是如果你想自定义的sql语句也想使用wrapper查询条件构造器则需要在mapper接口中添加参数以及xml中也要有固定。
PageHelper
PageHelper用于查询语句分页让分页更简单、代码更优雅。
参考
MyBatis-Plus 分页查询以及自定义sql分页 参考URL: https://blog.csdn.net/weixin_38111957/article/details/91554108?depth_1-utm_sourcedistribute.pc_relevant.none-taskutm_sourcedistribute.pc_relevant.none-task mybatis-plus分页查询 参考URL: https://www.jianshu.com/p/43bfe6fe8d89