Java操作MongoDB采用的是MongoRepository
Java怎么實現MongoDB分頁的功能?
慕工程0101907
2018-08-19 10:07:05
TA貢獻1815條經驗 獲得超6個贊
// 這個是我一個工程里的一段代碼,`template`是`MongoTemplate`的實例
return template.find(Query.query(criteria)
.with(new Sort(Sort.Direction.DESC ,"createTime"))
.with(new PageRequest(page ,limit)) ,
PushMessage.class) ;
// 如果是`MongoRepository`,我看里面有一個方法
Page<T> findAll(Pageable pageable);
// 我沒用過,題主自己研究一下吧。
舉報