I am trying to configure Pageable and PageRequest for page number starting from 1 instead of 0. Using below code Pageable is configured successfully:
@Configuration
@EnableSpringDataWebSupport
public class JPAConfiguration {
@Bean
Pageable HandlerMethodArgumentResolverCustomizer pageCustomizer(){
returns -> p.setOneIndexedParameters(true);
}
}
And now if I call endpoint using:
/myEndpoint?page=1&size=2
I get the records of first page which means 1-based page size is working. However the response has below information related to pagination:
"totalElements": 9,
"last": false,
"totalPages": 5,
"size": 2,
"number": 0,
"numberOfElements": 2,
"first": true,
"sort": {
"sorted": true,
"unsorted": false
}
If you notice the 'number' is 0 which means it is still 0-based. How can I configure it to be 1-based?
Thanks in advance.
I am using: SpringBoot:2.0.0, spring-data-commons: 2.0.5