Spring 5: MVC controller argument pageable doesn't get initialised

130 Views Asked by At

I have a controller like so:

@GetMapping(value = "/list")
@PreAuthorize("@authService.hasPermission('read')")
public Page<SomeObject> getlist(
        @PageableDefault(page = 0, size = 10, sort = "id")
                Pageable pageable,
        @RequestHeader HttpHeaders headers) {
    log.info(pageable.toString());
    // Some code
}

Now when I hit this API endpoint with:

http://some-ip/list?pageNumber=1&pageSize=1

The pageable is not initialized with these values and I see the below log.

 Page request [number: 0, size 10, sort: id: ASC]

I have tried manually accepting the page size and number and building the pageable myself, that seems to work just fine but the pageable argument in my controller doesn't seem to get initialized. I have no clue why.

I have seen this thread already but it doesn't work for me.

0

There are 0 best solutions below