Class RequestParamArgumentResolver
java.lang.Object
org.springframework.web.service.invoker.AbstractNamedValueArgumentResolver
org.springframework.web.service.invoker.RequestParamArgumentResolver
- All Implemented Interfaces:
- HttpServiceArgumentResolver
HttpServiceArgumentResolver for @RequestParam
annotated arguments.
When "content-type" is set to
"application/x-www-form-urlencoded", request parameters are encoded
in the request body. Otherwise, they are added as URL query parameters.
The argument may be:
- Map<String, ?>or- MultiValueMap<String, ?>with multiple request parameter and value(s).
- Collectionor an array of request parameters.
- An individual request parameter.
Individual request parameters may be Strings or Objects to be converted to
String values through the configured ConversionService.
If the value is required but null, IllegalArgumentException
is raised. The value is not required if:
- RequestParam.required()is set to- false
- RequestParam.defaultValue()provides a fallback value
- The argument is declared as Optional
- Since:
- 6.0
- Author:
- Rossen Stoyanchev
- 
Nested Class SummaryNested classes/interfaces inherited from class AbstractNamedValueArgumentResolverAbstractNamedValueArgumentResolver.NamedValueInfo
- 
Field SummaryFields inherited from class AbstractNamedValueArgumentResolverlogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddRequestValue(String name, Object value, MethodParameter parameter, HttpRequestValues.Builder requestValues) Add the given, single request value.createNamedValueInfo(MethodParameter parameter) Return information about the request value, ornullif the parameter does not represent a request value of interest.createNamedValueInfo(MethodParameter parameter, HttpRequestValues.Metadata metadata) Variant ofAbstractNamedValueArgumentResolver.createNamedValueInfo(MethodParameter)that also provides access to the static values set from@HttpExchangeattributes.booleanReturn the setting forfavorSingleValue.protected booleanWhether the content type is form data, or it is a multipart request.voidsetFavorSingleValue(boolean favorSingleValue) Whether to format multiple values (for example, collection, array) as a single String value through the configuredConversionServiceunless the content type is form data, or it is a multipart request.protected booleansupportsMultipleValues(MethodParameter parameter, HttpRequestValues.Metadata metadata) Determine whether the resolver should send multi-value request parameters as individual values.Methods inherited from class AbstractNamedValueArgumentResolverresolve
- 
Constructor Details- 
RequestParamArgumentResolver
 
- 
- 
Method Details- 
setFavorSingleValuepublic void setFavorSingleValue(boolean favorSingleValue) Whether to format multiple values (for example, collection, array) as a single String value through the configuredConversionServiceunless the content type is form data, or it is a multipart request.By default, this is falsein which case formatting is not applied, and a separate parameter with the same name is created for each value.- Since:
- 6.2
 
- 
isFavorSingleValue
- 
createNamedValueInfoprotected @Nullable AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(MethodParameter parameter, HttpRequestValues.Metadata metadata) Description copied from class:AbstractNamedValueArgumentResolverVariant ofAbstractNamedValueArgumentResolver.createNamedValueInfo(MethodParameter)that also provides access to the static values set from@HttpExchangeattributes.- Overrides:
- createNamedValueInfoin class- AbstractNamedValueArgumentResolver
 
- 
createNamedValueInfoprotected AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(MethodParameter parameter) Description copied from class:AbstractNamedValueArgumentResolverReturn information about the request value, ornullif the parameter does not represent a request value of interest.- Specified by:
- createNamedValueInfoin class- AbstractNamedValueArgumentResolver
 
- 
supportsMultipleValuesprotected boolean supportsMultipleValues(MethodParameter parameter, HttpRequestValues.Metadata metadata) Determine whether the resolver should send multi-value request parameters as individual values. If not, they are formatted to a single String value. The default implementation usesisFavorSingleValue()to decide unless the content type is form data, or it is a multipart request.- Since:
- 6.2
 
- 
isFormOrMultipartContentWhether the content type is form data, or it is a multipart request.- Since:
- 6.2
 
- 
addRequestValueprotected void addRequestValue(String name, Object value, MethodParameter parameter, HttpRequestValues.Builder requestValues) Description copied from class:AbstractNamedValueArgumentResolverAdd the given, single request value. This may be called multiples times if the request value is multivalued.If the resolver was created with a ConversionService, the value will have been converted to a String and may be cast down.- Specified by:
- addRequestValuein class- AbstractNamedValueArgumentResolver
- Parameters:
- name- the request value name
- value- the value
- parameter- the method parameter type, nested if Map, List/array, or Optional
- requestValues- builder to add the request value to
 
 
-