Package org.springframework.data.web
Class PageableHandlerMethodArgumentResolverSupport
java.lang.Object
org.springframework.data.web.PageableHandlerMethodArgumentResolverSupport
- Direct Known Subclasses:
- PageableHandlerMethodArgumentResolver,- ReactivePageableHandlerMethodArgumentResolver
Base class providing methods for handler method argument resolvers to create paging information from web requests and
 thus allows injecting 
Pageable instances into controller methods. Request properties to be parsed can be
 configured defaulting to page for the page number and size for the page size.
 
 Parameters can be prefixed to disambiguate from other parameters in the request if
 necessary.
- Since:
- 2.2
- Author:
- Mark Paluch, Vedran Pavic
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected intRetrieves the maximum page size to be accepted.protected PageablegetPageable(MethodParameter methodParameter, String pageString, String pageSizeString) protected StringRetrieves the parameter name to be used to find the page number in the request.protected StringgetParameterNameToUse(String source, MethodParameter parameter) Returns the name of the request parameter to find thePageableinformation in.protected StringRetrieves the parameter name to be used to find the page size in the request.booleanisFallbackPageable(Pageable pageable) Returns whether the givenPageableis the fallback one.protected booleanIndicates whether to expose and assume 1-based page number indexes in the request parameters.voidsetFallbackPageable(Pageable fallbackPageable) Configures thePageableto be used as fallback in case noPageableDefaultcan be found at the method parameter to be resolved.voidsetMaxPageSize(int maxPageSize) Configures the maximum page size to be accepted.voidsetOneIndexedParameters(boolean oneIndexedParameters) Configures whether to expose and assume 1-based page number indexes in the request parameters.voidsetPageParameterName(String pageParameterName) Configures the parameter name to be used to find the page number in the request.voidConfigures a general prefix to be prepended to the page number and page size parameters.voidsetQualifierDelimiter(String qualifierDelimiter) The delimiter to be used between the qualifier and the actual page number and size properties.voidsetSizeParameterName(String sizeParameterName) Configures the parameter name to be used to find the page size in the request.
- 
Constructor Details- 
PageableHandlerMethodArgumentResolverSupportpublic PageableHandlerMethodArgumentResolverSupport()
 
- 
- 
Method Details- 
setFallbackPageableConfigures thePageableto be used as fallback in case noPageableDefaultcan be found at the method parameter to be resolved.If you set this to Pageable#unpaged(), be aware that your controller methods will get an unpagedinstance handed into them in case noPageabledata can be found in the request.- Parameters:
- fallbackPageable- the- Pageableto be used as general fallback.
 
- 
isFallbackPageableReturns whether the givenPageableis the fallback one.- Parameters:
- pageable- can be null.
- Returns:
 
- 
setMaxPageSizepublic void setMaxPageSize(int maxPageSize) Configures the maximum page size to be accepted. This allows to put an upper boundary of the page size to prevent potential attacks trying to issue anOutOfMemoryError. Defaults toDEFAULT_MAX_PAGE_SIZE.- Parameters:
- maxPageSize- the maxPageSize to set
 
- 
getMaxPageSizeprotected int getMaxPageSize()Retrieves the maximum page size to be accepted. This allows to put an upper boundary of the page size to prevent potential attacks trying to issue anOutOfMemoryError. Defaults toDEFAULT_MAX_PAGE_SIZE.- Returns:
- the maximum page size allowed.
 
- 
setPageParameterNameConfigures the parameter name to be used to find the page number in the request. Defaults topage.- Parameters:
- pageParameterName- the parameter name to be used, must not be null or empty.
 
- 
getPageParameterNameRetrieves the parameter name to be used to find the page number in the request. Defaults topage.- Returns:
- the parameter name to be used, never null or empty.
 
- 
setSizeParameterNameConfigures the parameter name to be used to find the page size in the request. Defaults tosize.- Parameters:
- sizeParameterName- the parameter name to be used, must not be null or empty.
 
- 
getSizeParameterNameRetrieves the parameter name to be used to find the page size in the request. Defaults tosize.- Returns:
- the parameter name to be used, never null or empty.
 
- 
setPrefixConfigures a general prefix to be prepended to the page number and page size parameters. Useful to namespace the property names used in case they are clashing with ones used by your application. By default, no prefix is used.- Parameters:
- prefix- the prefix to be used or null to reset to the default.
 
- 
setQualifierDelimiterThe delimiter to be used between the qualifier and the actual page number and size properties. Defaults to_. So a qualifier offoowill result in a page number parameter offoo_page.- Parameters:
- qualifierDelimiter- the delimiter to be used or null to reset to the default.
 
- 
setOneIndexedParameterspublic 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
 
- 
isOneIndexedParametersprotected boolean isOneIndexedParameters()Indicates 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.- Returns:
- whether to assume 1-based page number indexes in the request parameters.
 
- 
getPageable
- 
getParameterNameToUseReturns the name of the request parameter to find thePageableinformation in. Inspects the givenMethodParameterforQualifierpresent and prefixes the given source parameter name with it.- Parameters:
- source- the basic parameter name.
- parameter- the- MethodParameterpotentially qualified.
- Returns:
- the name of the request parameter.
 
 
-