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();