public class PathVariableMethodArgumentResolver extends AbstractNamedValueSyncArgumentResolver
PathVariable
.
An @PathVariable
is a named value that gets resolved from a URI
template variable. It is always required and does not have a default value
to fall back on. See the base class
AbstractNamedValueMethodArgumentResolver
for more information on how named values are processed.
If the method parameter type is Map
, the name specified in the
annotation is used to resolve the URI variable String value. The value is
then converted to a Map
via type conversion, assuming a suitable
Converter
.
PathVariableMapMethodArgumentResolver
AbstractNamedValueArgumentResolver.NamedValueInfo
logger
Constructor and Description |
---|
PathVariableMethodArgumentResolver(ConfigurableBeanFactory factory,
ReactiveAdapterRegistry registry)
Create a new
PathVariableMethodArgumentResolver . |
Modifier and Type | Method and Description |
---|---|
protected AbstractNamedValueArgumentResolver.NamedValueInfo |
createNamedValueInfo(MethodParameter parameter)
Create the
AbstractNamedValueArgumentResolver.NamedValueInfo object for the given method parameter. |
protected void |
handleMissingValue(String name,
MethodParameter parameter)
Invoked when a named value is required, but
AbstractNamedValueArgumentResolver.resolveName(String, MethodParameter, ServerWebExchange) returned
null and there is no default value. |
protected void |
handleResolvedValue(Object arg,
String name,
MethodParameter parameter,
Model model,
ServerWebExchange exchange)
Invoked after a value is resolved.
|
protected Object |
resolveNamedValue(String name,
MethodParameter parameter,
ServerWebExchange exchange)
Actually resolve the value synchronously.
|
boolean |
supportsParameter(MethodParameter parameter)
Whether this resolver supports the given method parameter.
|
resolveArgument, resolveArgumentValue, resolveName
handleMissingValue
checkAnnotatedParamNoReactiveWrapper, checkParameterType, checkParameterTypeNoReactiveWrapper, getAdapterRegistry
public PathVariableMethodArgumentResolver(@Nullable ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry)
PathVariableMethodArgumentResolver
.factory
- a bean factory to use for resolving ${...}
placeholder and #{...}
SpEL expressions in default values;
or null
if default values are not expected to contain expressionsregistry
- for checking reactive type wrapperspublic boolean supportsParameter(MethodParameter parameter)
HandlerMethodArgumentResolver
parameter
- the method parameterprotected 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 Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange)
AbstractNamedValueSyncArgumentResolver
resolveNamedValue
in class AbstractNamedValueSyncArgumentResolver
protected void handleMissingValue(String name, MethodParameter parameter)
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 parameterprotected void handleResolvedValue(@Nullable Object arg, String name, MethodParameter parameter, Model model, ServerWebExchange exchange)
AbstractNamedValueArgumentResolver
handleResolvedValue
in class AbstractNamedValueArgumentResolver
arg
- the resolved argument valuename
- the argument nameparameter
- the argument parameter typemodel
- the modelexchange
- the current exchange