当前位置:   article > 正文

java 关于mongodb的分页查询_java mongodb分页查询

java mongodb分页查询

java 关于mongodb的分页查询

		//自定义条件查询

        //定义条件匹配器
        ExampleMatcher exampleMatcher = ExampleMatcher.matching().withMatcher("条件", ExampleMatcher.GenericPropertyMatchers.contains());

        //定义条件对象Example
        Example<MonitorInfo> example = Example.of(new MonitorInfo(),exampleMatcher);

        //分页参数
        if(page <=0){
            page = 1;
        }
        page = page -1;
        if(size<=0){
            size = 10;
        }
        Pageable pageable = PageRequest.of(page,size);
        Page<MonitorInfo> all = monitorInfoMongoResponse.findAll(example,pageable);//实现自定义条件查询并且分页查询
        List<MonitorInfo> monitorInfos = all.getContent();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号