Class PathVariableMethodArgumentResolver
java.lang.Object
org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver
- All Implemented Interfaces:
org.springframework.web.method.support.HandlerMethodArgumentResolver
,org.springframework.web.method.support.UriComponentsContributor
public class PathVariableMethodArgumentResolver
extends org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
implements org.springframework.web.method.support.UriComponentsContributor
Resolves method arguments annotated with an @
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
or PropertyEditor
has been
registered.
A WebDataBinder
is invoked to apply type conversion to resolved path variable
values that don't yet match the method parameter type.
- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Arjen Poutsma, Juergen Hoeller
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.NamedValueInfo
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
contributeMethodArgument
(org.springframework.core.MethodParameter parameter, Object value, org.springframework.web.util.UriComponentsBuilder builder, Map<String, Object> uriVariables, org.springframework.core.convert.ConversionService conversionService) protected org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.NamedValueInfo
createNamedValueInfo
(org.springframework.core.MethodParameter parameter) protected String
formatUriValue
(org.springframework.core.convert.ConversionService cs, org.springframework.core.convert.TypeDescriptor sourceType, Object value) protected void
handleMissingValue
(String name, org.springframework.core.MethodParameter parameter) protected void
handleMissingValueAfterConversion
(String name, org.springframework.core.MethodParameter parameter, org.springframework.web.context.request.NativeWebRequest request) protected void
handleResolvedValue
(Object arg, String name, org.springframework.core.MethodParameter parameter, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest request) protected Object
resolveName
(String name, org.springframework.core.MethodParameter parameter, org.springframework.web.context.request.NativeWebRequest request) boolean
supportsParameter
(org.springframework.core.MethodParameter parameter) Methods inherited from class org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
handleMissingValue, resolveArgument
-
Constructor Details
-
PathVariableMethodArgumentResolver
public PathVariableMethodArgumentResolver()
-
-
Method Details
-
supportsParameter
public boolean supportsParameter(org.springframework.core.MethodParameter parameter) - Specified by:
supportsParameter
in interfaceorg.springframework.web.method.support.HandlerMethodArgumentResolver
- Specified by:
supportsParameter
in interfaceorg.springframework.web.method.support.UriComponentsContributor
-
createNamedValueInfo
protected org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.NamedValueInfo createNamedValueInfo(org.springframework.core.MethodParameter parameter) - Specified by:
createNamedValueInfo
in classorg.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
-
resolveName
@Nullable protected Object resolveName(String name, org.springframework.core.MethodParameter parameter, org.springframework.web.context.request.NativeWebRequest request) throws Exception - Specified by:
resolveName
in classorg.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
- Throws:
Exception
-
handleMissingValue
protected void handleMissingValue(String name, org.springframework.core.MethodParameter parameter) throws org.springframework.web.bind.ServletRequestBindingException - Overrides:
handleMissingValue
in classorg.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
- Throws:
org.springframework.web.bind.ServletRequestBindingException
-
handleMissingValueAfterConversion
protected void handleMissingValueAfterConversion(String name, org.springframework.core.MethodParameter parameter, org.springframework.web.context.request.NativeWebRequest request) throws Exception - Overrides:
handleMissingValueAfterConversion
in classorg.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
- Throws:
Exception
-
handleResolvedValue
protected void handleResolvedValue(@Nullable Object arg, String name, org.springframework.core.MethodParameter parameter, @Nullable org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest request) - Overrides:
handleResolvedValue
in classorg.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver
-
contributeMethodArgument
public void contributeMethodArgument(org.springframework.core.MethodParameter parameter, Object value, org.springframework.web.util.UriComponentsBuilder builder, Map<String, Object> uriVariables, org.springframework.core.convert.ConversionService conversionService) - Specified by:
contributeMethodArgument
in interfaceorg.springframework.web.method.support.UriComponentsContributor
-
formatUriValue
-