Manu :
I am using Spring Boot 2 and I have write a @RestController
within a @GetMapping
that takes a Pageable
as parameter.
@GetMapping
public ResponseEntity<Page<AppointmentTO>> findAll(Pageable pageable) {
Page<AppointmentTO> page = appointmentService.findAll(pageable);
return ResponseEntity.ok(page);
}
The problem is the following:
By each request, the queries-parameters pageSize
and offset
are always reset to default when they arrived in Spring Boot Backend (?offset=0&pageSize=20
), however I send different parameters in the url of my request (?offset=15&pageSize=5
for example).
i.bondarenko :
Spring Boot maps the request params to org.springframework.data.domain.PageRequest
that extends AbstractPageRequest
AbstractPageRequest implements Pageable, Serializable {
...
private final int page;
private final int size;
public long getOffset() {
return (long)this.page * (long)this.size;
}
...
You should use following url:
http://localhost:8080?page=3&size=5
Also you could add sorting by ...&sort=name
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326944&siteId=1