I'm trying to get Spring Data's web pagination working. It's described here:
Here's my Java (Spring Web MVC @Controller handler method):
@RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(
@PageableDefaults(value = 50, pageNumber = 0) Pageable pageable,
Model model) {
log.debug("Params: pageNumber={}, pageSize={}",
pageable.getPageNumber(), pageable.getPageSize());
...
}
And here's my Spring configuration:
<mvc:annotation-driven>
<mvc:argument-resolvers>
<bean class="org.springframework.data.web.PageableArgumentResolver" />
</mvc:argument-resolvers>
</mvc:annotation-driven>
(It appears that the configuration above is the way to do this now; the configuration approach described in the link is deprecated.)
When I actually try to control the pagination using the page
and page.size
parameters, the latter works just fine, but the former doesn't. For example, if I hit
http://localhost:8080/myapp/list?page=14&page.size=42
the log output is
Params: pageNumber=0, pageSize=42
So I know that the argument resolver is kicking in, but not sure why it's not resolving the page number. I've tried a bunch of other param names (e.g. page.number, pageNumber, page.num, etc.) and none of them work.
Is this working for anybody else?