I have the following get function which should return trips inside of a page with optional specifications.
@GetMapping("/trip")
Page<Trip> all(@SearchSpec Specification<Trip> specs,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "1000") int pageSize) {
//return repository.findAll(Specification.where(specs));
return repository.findAll(Specification.where(specs), PageRequest.of(page, pageSize, Sort.by("searchKey").ascending()));
}
Now when I make the following request to my API:
http://localhost:8080/trip?page=0&pageSize=2&search=departureAirport:'AMS'
I get back 2 records(trips) from my API which is correct. When I change the request to:
http://localhost:8080/trip?page=1&pageSize=2&search=departureAirport:'AMS'
So to the next page, I get the next 2 records(trips) from my API which is also correct, but as soon as I want to go to page 2 the API returns the same records as on page 1. So every page above page 1 returns the same records.
I am able to increase the pageSize and when I do this the API returns more records, but again every page above 1 returns the same. So only the data on page 0 and 1 is different.
I tried removing the Specification and the sorting but this didn't fix the problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…