Top Description Inners Constructors Methods
org.springframework.web.method.annotation

public Class ExpressionValueMethodArgumentResolver

extends AbstractNamedValueMethodArgumentResolver
Class Inheritance
Imports
jakarta.servlet.ServletException, org.springframework.beans.factory.annotation.Value, org.springframework.beans.factory.config.ConfigurableBeanFactory, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.bind.WebDataBinder, org.springframework.web.context.request.NativeWebRequest

Resolves method arguments annotated with @Value.

An @Value does not have a name but gets resolved from the default value string, which may contain ${...} placeholder or Spring Expression Language #{...} expressions.

A WebDataBinder may be invoked to apply type conversion to resolved argument value.

Author
Rossen Stoyanchev
Since
3.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public
ExpressionValueMethodArgumentResolver(ConfigurableBeanFactory
a bean factory to use for resolving ${...} placeholder and #{...} SpEL expressions in default values; or null if default values are not expected to contain expressions
beanFactory
)

Create a new ExpressionValueMethodArgumentResolver instance.

Method Summary

Modifier and TypeMethod and Description
protected AbstractNamedValueMethodArgumentResolver.NamedValueInfo
createNamedValueInfo(MethodParameter
the method parameter
parameter
)

Implements abstract org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.createNamedValueInfo.

Create the NamedValueInfo object for the given method parameter.

protected void
handleMissingValue(String
the name for the value
name
,
MethodParameter
the method parameter
parameter
)

Overrides org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.handleMissingValue.

Invoked when a named value is required, but resolveName(String, MethodParameter, NativeWebRequest) returned null and there is no default value.

protected Object
resolveName(String
the name of the value being resolved
name
,
MethodParameter
the method parameter to resolve to an argument value (pre-nested in case of a java.util.Optional declaration)
parameter
,
NativeWebRequest
the current request
webRequest
)

Implements abstract org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveName.

Resolve the given parameter type and value name into an argument value.

public boolean
supportsParameter(MethodParameter
the method parameter to check
parameter
)

Implements org.springframework.web.method.support.HandlerMethodArgumentResolver.supportsParameter.

Whether the given method parameter is supported by this resolver.

Inherited from org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver:
handleMissingValuehandleMissingValueAfterConversionhandleResolvedValueresolveArgument

Constructor Detail

ExpressionValueMethodArgumentResolverback to summary
public ExpressionValueMethodArgumentResolver(ConfigurableBeanFactory beanFactory)

Create a new ExpressionValueMethodArgumentResolver instance.

Parameters
beanFactory:ConfigurableBeanFactory

a bean factory to use for resolving ${...} placeholder and #{...} SpEL expressions in default values; or null if default values are not expected to contain expressions

Method Detail

createNamedValueInfoback to summary
protected AbstractNamedValueMethodArgumentResolver.NamedValueInfo createNamedValueInfo(MethodParameter parameter)

Implements abstract org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.createNamedValueInfo.

Doc from org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.createNamedValueInfo.

Create the NamedValueInfo object for the given method parameter. Implementations typically retrieve the method annotation by means of MethodParameter#getParameterAnnotation(Class).

Parameters
parameter:MethodParameter

the method parameter

Returns:AbstractNamedValueMethodArgumentResolver.NamedValueInfo

the named value information

Annotations
@Override
handleMissingValueback to summary
protected void handleMissingValue(String name, MethodParameter parameter) throws ServletException

Overrides org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.handleMissingValue.

Doc from org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.handleMissingValue.

Invoked when a named value is required, but resolveName(String, MethodParameter, NativeWebRequest) returned null and there is no default value. Subclasses typically throw an exception in this case.

Parameters
name:String

the name for the value

parameter:MethodParameter

the method parameter

Annotations
@Override
resolveNameback to summary
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest webRequest) throws Exception

Implements abstract org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveName.

Doc from org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveName.

Resolve the given parameter type and value name into an argument value.

Parameters
name:String

the name of the value being resolved

parameter:MethodParameter

the method parameter to resolve to an argument value (pre-nested in case of a java.util.Optional declaration)

webRequest:NativeWebRequest

the current request

Returns:Object

the resolved argument (may be null)

Annotations
@Override
@Nullable
Exceptions
Exception:
in case of errors
supportsParameterback to summary
public boolean supportsParameter(MethodParameter parameter)

Implements org.springframework.web.method.support.HandlerMethodArgumentResolver.supportsParameter.

Doc from org.springframework.web.method.support.HandlerMethodArgumentResolver.supportsParameter.

Whether the given method parameter is supported by this resolver.

Parameters
parameter:MethodParameter

the method parameter to check

Returns:boolean

true if this resolver supports the supplied parameter; false otherwise

Annotations
@Override
org.springframework.web.method.annotation back to summary

private final Class ExpressionValueMethodArgumentResolver.ExpressionValueNamedValueInfo

extends NamedValueInfo
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Constructor Detail

ExpressionValueNamedValueInfoback to summary
private ExpressionValueNamedValueInfo(Value annotation)