Spring数据分页工作不正确



我试图使用分页从我的存储库中获取数据,但我得到了奇怪的结果。

Contoroller代码:

@GetMapping("/warehouses")
@Cacheable(value = "warehouses")
public List<Warehouse> findWarehouses(@RequestParam(name = "page", required = false, defaultValue = "1") int page,
@RequestParam(name = "size", required = false, defaultValue = "10") int size) {
return warehouseRepository.findAll(PageRequest.of(page, size)).getContent();
}

Repository使用默认的MongoRepository方法。

我正在发送请求并获得下一个结果。第一个查询第二个查询第三个查询第四个查询第五个查询第六个查询

这是我在数据库中存储的数据

[
{
_id: 'Compluter Inc',
merchandiseQuantity: { computer: 16, vacine: 10, bebra: 6 },
position: { x: 43, y: 12 },
_class: 'com.logistic.project.model.Warehouse'
},
{
_id: 'Bebra',
merchandiseQuantity: { grivna: 20, laptop: 100, beer: 1 },
position: { x: 21, y: 89 },
_class: 'com.logistic.project.model.Warehouse'
},
{
_id: 'LG',
merchandiseQuantity: { chair: 90, cup: 13, notebook: 18 },
position: { x: 15, y: 90 },
_class: 'com.logistic.project.model.Warehouse'
},
{
_id: 'Abchihba',
merchandiseQuantity: { gun: 54, computer: 4, answer: 42 },
position: { x: 567, y: 890 },
_class: 'com.logistic.project.model.Warehouse'
},
{
_id: 'Node',
merchandiseQuantity: { grinva: 6, gun: 16, charger: 132 },
position: { x: 389, y: 54 },
_class: 'com.logistic.project.model.Warehouse'
},
{
_id: 'Meta',
merchandiseQuantity: { computer: 16, vacine: 10, bebra: 6 },
position: { x: 321, y: 590 },
_class: 'com.logistic.project.model.Warehouse'
} 
]

感谢回答(

没有问题,我忘记了分页从0 开始

最新更新