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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontributeMethodArgument(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.NamedValueInfocreateNamedValueInfo(org.springframework.core.MethodParameter parameter) protected StringformatUriValue(org.springframework.core.convert.ConversionService cs, org.springframework.core.convert.TypeDescriptor sourceType, Object value) protected voidhandleMissingValue(String name, org.springframework.core.MethodParameter parameter) protected voidhandleMissingValueAfterConversion(String name, org.springframework.core.MethodParameter parameter, org.springframework.web.context.request.NativeWebRequest request) protected voidhandleResolvedValue(Object arg, String name, org.springframework.core.MethodParameter parameter, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest request) protected ObjectresolveName(String name, org.springframework.core.MethodParameter parameter, org.springframework.web.context.request.NativeWebRequest request) booleansupportsParameter(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:
supportsParameterin interfaceorg.springframework.web.method.support.HandlerMethodArgumentResolver- Specified by:
supportsParameterin interfaceorg.springframework.web.method.support.UriComponentsContributor
-
createNamedValueInfo
protected org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.NamedValueInfo createNamedValueInfo(org.springframework.core.MethodParameter parameter) - Specified by:
createNamedValueInfoin 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:
resolveNamein 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:
handleMissingValuein 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:
handleMissingValueAfterConversionin 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:
handleResolvedValuein 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:
contributeMethodArgumentin interfaceorg.springframework.web.method.support.UriComponentsContributor
-
formatUriValue
-