Top Description Inners Constructors Methods
org.springframework.web.reactive.result.method.annotation

public Class PathVariableMethodArgumentResolver

extends AbstractNamedValueSyncArgumentResolver
Class Inheritance
Imports
java.util.Collections, .Map, org.springframework.beans.factory.config.ConfigurableBeanFactory, org.springframework.core.MethodParameter, .ReactiveAdapterRegistry, org.springframework.core.convert.converter.Converter, org.springframework.lang.Nullable, org.springframework.ui.Model, org.springframework.util.Assert, .StringUtils, org.springframework.web.bind.annotation.PathVariable, .ValueConstants, org.springframework.web.reactive.HandlerMapping, org.springframework.web.server.ServerErrorException, .ServerWebExchange

Resolves method arguments annotated with @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 org.springframework.web.method.annotation.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.

Authors
Rossen Stoyanchev, Juergen Hoeller
Since
5.0
See Also
PathVariableMapMethodArgumentResolver

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public
PathVariableMethodArgumentResolver(ConfigurableBeanFactory
a bean factory to use for resolving ${...} placeholder and #{...} SpEL expressions in default values; or null if default values are not expected to contain expressions
factory
,
ReactiveAdapterRegistry
for checking reactive type wrappers
registry
)

Create a new PathVariableMethodArgumentResolver.

Method Summary

Modifier and TypeMethod and Description
protected AbstractNamedValueArgumentResolver.NamedValueInfo
protected void
handleMissingValue(String
the name for the value
name
,
MethodParameter
the method parameter
parameter
)

Overrides org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.handleMissingValue.

Invoked when a named value is required, but resolveName(String, MethodParameter, ServerWebExchange) returned null and there is no default value.

protected void
handleResolvedValue(Object
the resolved argument value
arg
,
String
the argument name
name
,
MethodParameter
the argument parameter type
parameter
,
Model
the model
model
,
ServerWebExchange
the current exchange
exchange
)

Overrides org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.handleResolvedValue.

Invoked after a value is resolved.

protected Object
private boolean
singlePathVariable(PathVariable pathVariable, Class<?> type)

public boolean
supportsParameter(MethodParameter
the method parameter
parameter
)

Implements org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.supportsParameter.

Whether this resolver supports the given method parameter.

Inherited from org.springframework.web.reactive.result.method.annotation.AbstractNamedValueSyncArgumentResolver:
resolveArgumentresolveArgumentValueresolveName

Constructor Detail

PathVariableMethodArgumentResolverback to summary
public PathVariableMethodArgumentResolver(ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry)

Create a new PathVariableMethodArgumentResolver.

Parameters
factory:ConfigurableBeanFactory

a bean factory to use for resolving ${...} placeholder and #{...} SpEL expressions in default values; or null if default values are not expected to contain expressions

registry:ReactiveAdapterRegistry

for checking reactive type wrappers

Method Detail

createNamedValueInfoback to summary
protected AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(MethodParameter parameter)

Implements abstract org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.createNamedValueInfo.

Doc from org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.createNamedValueInfo.

Create the NamedValueInfo object for the given method parameter. Implementations typically retrieve the method annotation by means of MethodParameter#getParameterAnnotation(Class).

Parameters
parameter:MethodParameter

the method parameter

Returns:AbstractNamedValueArgumentResolver.NamedValueInfo

the named value information

Annotations
@Override
handleMissingValueback to summary
protected void handleMissingValue(String name, MethodParameter parameter)

Overrides org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.handleMissingValue.

Doc from org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.handleMissingValue.

Invoked when a named value is required, but resolveName(String, MethodParameter, ServerWebExchange) returned null and there is no default value. Subclasses typically throw an exception in this case.

Parameters
name:String

the name for the value

parameter:MethodParameter

the method parameter

Annotations
@Override
handleResolvedValueback to summary
protected void handleResolvedValue(Object arg, String name, MethodParameter parameter, Model model, ServerWebExchange exchange)

Overrides org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.handleResolvedValue.

Doc from org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver.handleResolvedValue.

Invoked after a value is resolved.

Parameters
arg:Object

the resolved argument value

name:String

the argument name

parameter:MethodParameter

the argument parameter type

model:Model

the model

exchange:ServerWebExchange

the current exchange

Annotations
@Override
resolveNamedValueback to summary
protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange)

Implements abstract org.springframework.web.reactive.result.method.annotation.AbstractNamedValueSyncArgumentResolver.resolveNamedValue.

Doc from org.springframework.web.reactive.result.method.annotation.AbstractNamedValueSyncArgumentResolver.resolveNamedValue.

Actually resolve the value synchronously.

Annotations
@Override
singlePathVariableback to summary
private boolean singlePathVariable(PathVariable pathVariable, Class<?> type)
supportsParameterback to summary
public boolean supportsParameter(MethodParameter parameter)

Implements org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.supportsParameter.

Doc from org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.supportsParameter.

Whether this resolver supports the given method parameter.

Parameters
parameter:MethodParameter

the method parameter

Annotations
@Override
org.springframework.web.reactive.result.method.annotation back to summary

private Class PathVariableMethodArgumentResolver.PathVariableNamedValueInfo

extends NamedValueInfo
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

PathVariableNamedValueInfoback to summary
public PathVariableNamedValueInfo(PathVariable annotation)