public interface WebArgumentResolver
A typical implementation could look like as follows:
public class MySpecialArgumentResolver implements WebArgumentResolver {
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) {
if (methodParameter.getParameterType().equals(MySpecialArg.class)) {
return new MySpecialArg("myValue");
}
return UNRESOLVED;
}
}org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#setCustomArgumentResolvers,
org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter#setCustomArgumentResolvers| Modifier and Type | Field and Description |
|---|---|
static Object |
UNRESOLVED
Marker to be returned when the resolver does not know how to
handle the given method parameter.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
resolveArgument(org.springframework.core.MethodParameter methodParameter,
NativeWebRequest webRequest)
Resolve an argument for the given handler method parameter within the given web request.
|
static final Object UNRESOLVED
Object resolveArgument(org.springframework.core.MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception
methodParameter - the handler method parameter to resolvewebRequest - the current web request, allowing access to the native request as wellUNRESOLVED if not resolvableException - in case of resolution failure