Top Description Fields Methods
org.springframework.web.bind.support

public Interface WebArgumentResolver

Annotations
@FunctionalInterface
Imports
org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.web.context.request.NativeWebRequest

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;
  }
}
Author
Juergen Hoeller
Since
2.5.2
See Also
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#setCustomArgumentResolvers

Field Summary

Modifier and TypeField and Description
public static final Object
UNRESOLVED

Marker to be returned when the resolver does not know how to handle the given method parameter.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the argument value, or UNRESOLVED if not resolvable
resolveArgument
(MethodParameter
the handler method parameter to resolve
methodParameter
,
NativeWebRequest
the current web request, allowing access to the native request as well
webRequest
)

Resolve an argument for the given handler method parameter within the given web request.

Field Detail

UNRESOLVEDback to summary
public static final Object UNRESOLVED

Marker to be returned when the resolver does not know how to handle the given method parameter.

Method Detail

resolveArgumentback to summary
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception

Resolve an argument for the given handler method parameter within the given web request.

Parameters
methodParameter:MethodParameter

the handler method parameter to resolve

webRequest:NativeWebRequest

the current web request, allowing access to the native request as well

Returns:Object

the argument value, or UNRESOLVED if not resolvable

Annotations
@Nullable
Exceptions
Exception:
in case of resolution failure