Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix defaultValue when using @PageableDefault together with one-indexed-parameters #2881

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pheyken
Copy link

@pheyken pheyken commented Jan 31, 2025

Hi,

we noticed that the default value for the page was 0 when having a spring-boot application with spring.data.web.pageable.one-indexed-parameters=true as well as using a @PageableDefault on the controller.

The @PageableDefault annotation has 0 as the default value for the page (see here). This is the desired behavior (as far as I can tell) as spring normalizes the pageable before injecting it into the controller method. This is done in this method.

So, e.g., if the newly added test controller was to be called with the following query parameters

/test1?prefix_pages=1

the injected pageable in the controller would return 0 for getPageNumber()

@GetMapping("/test1")
public String getPatientList1(
    @PageableDefault(size = 100, sort = { "someField", "someoTHER" }, direction = Sort.Direction.DESC) 
    @ParameterObject 
    Pageable pageable
) {
        System.out.println(pageable.getPageNumber()) // prints 0
	return "bla";
}

Let me know if you prefer to have a separate TestApp for this, happy to adjust this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant