Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Respect oneIndexedParameters property when serialising Page to JSON #3161

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

Open
clzola wants to merge 1 commit into spring-projects:main
base: main
Choose a base branch
Loading
from clzola:bugfix/page-model-one-index-pagination

Conversation

Copy link

@clzola clzola commented Sep 23, 2024

I have noticed when using Spring Data in my project, I can set property spring.data.web.one-indexed-parameters to true and have my page numbering start from 1 in my API. However when returning Page from controller, this value is not respected and it will always return page number decreased by 1.

This PR fixes that by adding oneIndexedParameters attribute to SpringDataJacksonConfiguration.PageModule class. I have also added PageModuleCustomizer to be used to define wether PageModule will assume 1-based page number indexes in the request parameters

In order to respect this property, a PageModuleCustomizer needs to be defined:

@Bean 
public PageModuleCustomizer pageModuleCustomizer() {
 return pageModule -> {
 pageModule.setOneIndexedParameters(true); 
 }
}

Also this bean can be defined in Spring Boot Autoconfigure project, so spring will automatically take care of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /