public class RequestParamMethodArgumentResolver extends AbstractNamedValueSyncArgumentResolver
RequestParam
.
This resolver can also be created in default resolution mode in which
simple types (int, long, etc.) not annotated with @RequestParam
are
also treated as request parameters with the parameter name derived from the
argument name.
If the method parameter type is Map
, the name specified in the
annotation is used to resolve the request parameter String value. The value is
then converted to a Map
via type conversion assuming a suitable
Converter
has been registered. Or if a request parameter name is not
specified the RequestParamMapMethodArgumentResolver
is used instead
to provide access to all request parameters in the form of a map.
RequestParamMapMethodArgumentResolver
Modifier and Type | Class and Description |
---|---|
private static class |
RequestParamMethodArgumentResolver.RequestParamNamedValueInfo |
AbstractNamedValueArgumentResolver.NamedValueInfo
Modifier and Type | Field and Description |
---|---|
private boolean |
useDefaultResolution |
Constructor and Description |
---|
RequestParamMethodArgumentResolver(ConfigurableBeanFactory beanFactory)
Class constructor.
|
RequestParamMethodArgumentResolver(ConfigurableBeanFactory beanFactory,
boolean useDefaultResolution)
Class constructor with a default resolution mode flag.
|
Modifier and Type | Method and Description |
---|---|
protected AbstractNamedValueArgumentResolver.NamedValueInfo |
createNamedValueInfo(MethodParameter parameter)
Create the
AbstractNamedValueArgumentResolver.NamedValueInfo object for the given method parameter. |
private MultiValueMap<java.lang.String,java.lang.String> |
getRequestParams(ServerWebExchange exchange) |
protected void |
handleMissingValue(java.lang.String name,
MethodParameter parameter,
ServerWebExchange exchange)
Invoked when a named value is required, but
AbstractNamedValueArgumentResolver.resolveName(String, MethodParameter, ServerWebExchange) returned
null and there is no default value. |
protected java.util.Optional<java.lang.Object> |
resolveNamedValue(java.lang.String name,
MethodParameter parameter,
ServerWebExchange exchange)
An abstract method for synchronous resolution of method argument values
that sub-classes must implement.
|
boolean |
supportsParameter(MethodParameter parameter) |
resolveArgumentValue, resolveName
handleMissingValue, handleResolvedValue, resolveArgument
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
resolveArgument
public RequestParamMethodArgumentResolver(ConfigurableBeanFactory beanFactory)
beanFactory
- a bean factory used for resolving ${...} placeholder
and #{...} SpEL expressions in default values, or null
if default
values are not expected to contain expressionspublic RequestParamMethodArgumentResolver(ConfigurableBeanFactory beanFactory, boolean useDefaultResolution)
beanFactory
- a bean factory used for resolving ${...} placeholder
and #{...} SpEL expressions in default values, or null
if default
values are not expected to contain expressionsuseDefaultResolution
- in default resolution mode a method argument
that is a simple type, as defined in BeanUtils.isSimpleProperty(java.lang.Class<?>)
,
is treated as a request parameter even if it isn't annotated, the
request parameter name is derived from the method parameter name.public boolean supportsParameter(MethodParameter parameter)
protected AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(MethodParameter parameter)
AbstractNamedValueArgumentResolver
AbstractNamedValueArgumentResolver.NamedValueInfo
object for the given method parameter.
Implementations typically retrieve the method annotation by means of
MethodParameter.getParameterAnnotation(Class)
.createNamedValueInfo
in class AbstractNamedValueArgumentResolver
parameter
- the method parameterprotected java.util.Optional<java.lang.Object> resolveNamedValue(java.lang.String name, MethodParameter parameter, ServerWebExchange exchange)
AbstractNamedValueSyncArgumentResolver
resolveNamedValue
in class AbstractNamedValueSyncArgumentResolver
name
- the name of the value being resolvedparameter
- the method parameter to resolve to an argument value
(pre-nested in case of a Optional
declaration)exchange
- the current exchangeprivate MultiValueMap<java.lang.String,java.lang.String> getRequestParams(ServerWebExchange exchange)
protected void handleMissingValue(java.lang.String name, MethodParameter parameter, ServerWebExchange exchange)
AbstractNamedValueArgumentResolver
AbstractNamedValueArgumentResolver.resolveName(String, MethodParameter, ServerWebExchange)
returned
null
and there is no default value. Subclasses typically throw an
exception in this case.handleMissingValue
in class AbstractNamedValueArgumentResolver
name
- the name for the valueparameter
- the method parameterexchange
- the current exchange