@FunctionalInterface 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; } }
RequestMappingHandlerAdapter.setCustomArgumentResolvers(java.util.List<org.springframework.web.method.support.HandlerMethodArgumentResolver>)
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(MethodParameter methodParameter,
NativeWebRequest webRequest)
Resolve an argument for the given handler method parameter within the given web request.
|
static final Object UNRESOLVED
@Nullable Object resolveArgument(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