MongoTemplate分页查询
解决方法:
下面查询第一页10条数据
Criteria where = new Criteria();
where.and("roles").is("管理员");
Query query=new Query(where);
long count = template.count(query, Designer.class);
Pageable pageable = new PageRequest(0,10);
List<Role> pageList = template.find(query.with(pageable).with(new Sort(new Sort.Order(Sort.Direction.DESC,"updateTime"))), Designer.class);
其中Designer是和mongodb表映射的对象,@Document(collection = "designer")