Class AbstractWebArgumentResolverAdapter
java.lang.Object
org.springframework.web.method.annotation.AbstractWebArgumentResolverAdapter
- All Implemented Interfaces:
HandlerMethodArgumentResolver
- Direct Known Subclasses:
ServletWebArgumentResolverAdapter
public abstract class AbstractWebArgumentResolverAdapter
extends Object
implements HandlerMethodArgumentResolver
An abstract base class adapting a
WebArgumentResolver
to the
HandlerMethodArgumentResolver
contract.
Note: This class is provided for backwards compatibility.
However it is recommended to re-write a WebArgumentResolver
as
HandlerMethodArgumentResolver
. Since supportsParameter(org.springframework.core.MethodParameter)
can only be implemented by actually resolving the value and then checking
the result is not WebArgumentResolver#UNRESOLVED
any exceptions
raised must be absorbed and ignored since it's not clear whether the adapter
doesn't support the parameter or whether it failed for an internal reason.
The HandlerMethodArgumentResolver
contract also provides access to
model attributes and to WebDataBinderFactory
(for type conversion).
- Since:
- 3.1
- Author:
- Arjen Poutsma, Rossen Stoyanchev
-
Constructor Summary
ConstructorDescriptionCreate a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract NativeWebRequest
Required for access to NativeWebRequest insupportsParameter(org.springframework.core.MethodParameter)
.resolveArgument
(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) Delegate to theWebArgumentResolver
instance.boolean
supportsParameter
(MethodParameter parameter) Actually resolve the value and check the resolved value is notWebArgumentResolver.UNRESOLVED
absorbing _any_ exceptions.
-
Constructor Details
-
AbstractWebArgumentResolverAdapter
Create a new instance.
-
-
Method Details
-
supportsParameter
Actually resolve the value and check the resolved value is notWebArgumentResolver.UNRESOLVED
absorbing _any_ exceptions.- Specified by:
supportsParameter
in interfaceHandlerMethodArgumentResolver
- Parameters:
parameter
- the method parameter to check- Returns:
true
if this resolver supports the supplied parameter;false
otherwise
-
resolveArgument
public @Nullable Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception Delegate to theWebArgumentResolver
instance.- Specified by:
resolveArgument
in interfaceHandlerMethodArgumentResolver
- Parameters:
parameter
- the method parameter to resolve. This parameter must have previously been passed toHandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter)
which must have returnedtrue
.mavContainer
- the ModelAndViewContainer for the current requestwebRequest
- the current requestbinderFactory
- a factory for creatingWebDataBinder
instances- Returns:
- the resolved argument value, or
null
if not resolvable - Throws:
IllegalStateException
- if the resolved value is not assignable to the method parameter.Exception
- in case of errors with the preparation of argument values
-
getWebRequest
Required for access to NativeWebRequest insupportsParameter(org.springframework.core.MethodParameter)
.
-