Set default page size for JPA Pageable Object

If you are talking about a Spring Data PagingAndSortingRepository you can set the default page size by using the @PageableDefault on a Controller method as follows:

public String listClients(@ModelAttribute FilterForm form, Model model, WebRequest request, @PageableDefault(sort = { "surname",
            "forename", "" }, value = 50) Pageable pageable) {


Or you can configure a global default using the following in your Spring config as shown below in both XML and Java config.

Note that newer versions of Spring Data use zero based page indexing while older versions used 1 for the first page. If your UI paging library expects 1 as first page then you can set the oneIndexedParameters property to true:

  • public void setOneIndexedParameters(boolean oneIndexedParameters)

Configures whether to expose and assume 1-based page number indexes in
the request parameters. Defaults to false, meaning a page number of 0
in the request equals the first page. If this is set to true, a page
number of 1 in the request will be considered the first page.

Parameters: oneIndexedParameters – the oneIndexedParameters to set

  • public void setFallbackPageable(Pageable fallbackPageable)

Configures the Pageable to be used as fallback in case no PageableDefault or
PageableDefaults (the latter only supported in legacy mode) can be
found at the method parameter to be resolved. If you set this to null,
be aware that you controller methods will get null handed into them in
case no Pageable data can be found in the request. Note, that doing so
will require you supply bot the page and the size parameter with the
requests as there will be no default for any of the parameters

Parameters: fallbackPageable – the Pageable to be used as general

In XML this looks like the following then:

        <bean class="">
            <property name="oneIndexedParameters" value="true"/>
            <property name="fallbackPageable">
                <bean class="">
                    <constructor-arg name="page" value="1" />
                    <constructor-arg name="size" value="10" />

In Java Config this looks like the below:

public class WebConfig extends WebMvcConfigurerAdapter {

    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
        resolver.setFallbackPageable(new PageRequest(1, 20));

Leave a Comment