Interface WebArgumentResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
SPI for resolving custom arguments for a specific handler method parameter.
Typically implemented to detect special parameter types, resolving
well-known argument values for them.
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; } }
- Since:
- 2.5.2
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Object
Marker to be returned when the resolver does not know how to handle the given method parameter. -
Method Summary
Modifier and TypeMethodDescriptionresolveArgument
(MethodParameter methodParameter, NativeWebRequest webRequest) Resolve an argument for the given handler method parameter within the given web request.
-
Field Details
-
UNRESOLVED
Marker to be returned when the resolver does not know how to handle the given method parameter.
-
-
Method Details
-
resolveArgument
@Nullable Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception Resolve an argument for the given handler method parameter within the given web request.- Parameters:
methodParameter
- the handler method parameter to resolvewebRequest
- the current web request, allowing access to the native request as well- Returns:
- the argument value, or
UNRESOLVED
if not resolvable - Throws:
Exception
- in case of resolution failure
-