spring-projects / spring-data-commons

Spring Data Commons. Interfaces and code shared between the various datastore specific implementations.
https://spring.io/projects/spring-data
Apache License 2.0
770 stars 670 forks source link

Allow paging to be 1-based [DATACMNS-1668] #2088

Open spring-projects-issues opened 4 years ago

spring-projects-issues commented 4 years ago

Greg Turnquist opened DATACMNS-1668 and commented

This started as a Spring HATEOAS issue, but it turns out, was actually observed in Spring Data REST. Spring Data REST's paging is based on Commons


Reference URL: https://github.com/spring-projects/spring-hateoas/issues/727

rhanton commented 1 week ago

+1 - Java dev here, so I love the idea of 0-based pagination, but it seems to make non-Java-devs' brains hurt. Would be handy to have a toggle somewhere to change this over, ideally something that isn't just a property but something I can control from a spring-boot helper-library level.

odrotbohm commented 1 week ago

You can use a bean of type PageableHandlerMethodArgumentResolverCustomizer to flip settings on PageableHandlerMethodArgumentResolver using setOneIndexedParameter(…). This setting has been available for over 10 years now.