Using Spring Data REST with JPA in version 2.1.0.
How can I configure the pagination in order to have the page argument starting at index 1 instead of 0 ?
I have tried setting a custom HateoasPageableHandlerMethodArgumentResolver
with an mvc:argument-resolvers
, but that doesn't work:
<mvc:annotation-driven>
<mvc:argument-resolvers>
<bean class="org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver">
<property name="oneIndexedParameters" value="true"/>
</bean>
</mvc:argument-resolvers>
</mvc:annotation-driven>
Note that this behaviour is perfectly coherent with the documentation for mvc:argument-resolver
that says:
Using this option does not override the built-in support for resolving handler method arguments. To customize the built-in support for argument resolution configure RequestMappingHandlerAdapter directly.
But how can I achieve this ? If possible, in a clean and elegant way ?
The easiest way to do so is to subclass
RepositoryRestMvcConfiguration
and include your class into your configuration:In your XML configuration, replace:
with
or import the custom class instead of the standard one in your JavaConfig file.
I have configured the
RequestMappingHandlerAdapter
using aBeanPostProcessor
, however I believe that's neither clean, nor elegant. That looks more like a hack. There must be a better way ! I'm giving the code below just for reference.