类 InvocableHandlerMethod
- java.lang.Object
- org.springframework.web.method.HandlerMethod
- org.springframework.web.method.support.InvocableHandlerMethod
public class InvocableHandlerMethod extends HandlerMethod
Extension ofHandlerMethod
that invokes the underlying method with argument values resolved from the current HTTP request through a list ofHandlerMethodArgumentResolver
.- 从以下版本开始:
- 3.1
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
嵌套类概要
从类继承的嵌套类/接口 org.springframework.web.method.HandlerMethod
HandlerMethod.HandlerMethodParameter
字段概要
从类继承的字段 org.springframework.web.method.HandlerMethod
logger
构造器概要
构造器 构造器 说明 InvocableHandlerMethod(Object bean, Method method)
Create an instance from a bean instance and a method.InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes)
Construct a new handler method with the given bean instance, method name and parameters.InvocableHandlerMethod(HandlerMethod handlerMethod)
Create an instance from aHandlerMethod
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Object
doInvoke(Object... args)
Invoke the handler method with the given argument values.protected Object[]
getMethodArgumentValues(NativeWebRequest request, ModelAndViewContainer mavContainer, Object... providedArgs)
Get the method argument values for the current request, checking the provided argument values and falling back to the configured argument resolvers.Object
invokeForRequest(NativeWebRequest request, ModelAndViewContainer mavContainer, Object... providedArgs)
Invoke the method after resolving its argument values in the context of the given request.void
setDataBinderFactory(WebDataBinderFactory dataBinderFactory)
Set theWebDataBinderFactory
to be passed to argument resolvers allowing them to create aWebDataBinder
for data binding and type conversion purposes.void
setHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
SetHandlerMethodArgumentResolvers
to use for resolving method argument values.void
setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).从类继承的方法 org.springframework.web.method.HandlerMethod
assertTargetBean, createWithResolvedBean, equals, findProvidedArgument, formatArgumentError, formatInvokeError, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getResolvedFromHandlerMethod, getResponseStatus, getResponseStatusReason, getReturnType, getReturnValueType, getShortLogMessage, hashCode, hasMethodAnnotation, isVoid, toString
构造器详细资料
InvocableHandlerMethod
public InvocableHandlerMethod(HandlerMethod handlerMethod)
Create an instance from aHandlerMethod
.
InvocableHandlerMethod
public InvocableHandlerMethod(Object bean, Method method)
Create an instance from a bean instance and a method.
InvocableHandlerMethod
public InvocableHandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException
Construct a new handler method with the given bean instance, method name and parameters.- 参数:
bean
- the object beanmethodName
- the method nameparameterTypes
- the method parameter types- 抛出:
NoSuchMethodException
- when the method cannot be found
方法详细资料
setHandlerMethodArgumentResolvers
public void setHandlerMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers)
SetHandlerMethodArgumentResolvers
to use for resolving method argument values.
setParameterNameDiscoverer
public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer)
Set the ParameterNameDiscoverer for resolving parameter names when needed (e.g. default request attribute name).Default is a
DefaultParameterNameDiscoverer
.
setDataBinderFactory
public void setDataBinderFactory(WebDataBinderFactory dataBinderFactory)
Set theWebDataBinderFactory
to be passed to argument resolvers allowing them to create aWebDataBinder
for data binding and type conversion purposes.
invokeForRequest
@Nullable public Object invokeForRequest(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception
Invoke the method after resolving its argument values in the context of the given request.Argument values are commonly resolved through
HandlerMethodArgumentResolvers
. TheprovidedArgs
parameter however may supply argument values to be used directly, i.e. without argument resolution. Examples of provided argument values include aWebDataBinder
, aSessionStatus
, or a thrown exception instance. Provided argument values are checked before argument resolvers.Delegates to
getMethodArgumentValues(org.springframework.web.context.request.NativeWebRequest, org.springframework.web.method.support.ModelAndViewContainer, java.lang.Object...)
and callsdoInvoke(java.lang.Object...)
with the resolved arguments.- 参数:
request
- the current requestmavContainer
- the ModelAndViewContainer for this requestprovidedArgs
- "given" arguments matched by type, not resolved- 返回:
- the raw value returned by the invoked method
- 抛出:
Exception
- raised if no suitable argument resolver can be found, or if the method raised an exception- 另请参阅:
getMethodArgumentValues(org.springframework.web.context.request.NativeWebRequest, org.springframework.web.method.support.ModelAndViewContainer, java.lang.Object...)
,doInvoke(java.lang.Object...)
getMethodArgumentValues
protected Object[] getMethodArgumentValues(NativeWebRequest request, @Nullable ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception
Get the method argument values for the current request, checking the provided argument values and falling back to the configured argument resolvers.The resulting array will be passed into
doInvoke(java.lang.Object...)
.- 抛出:
Exception
- 从以下版本开始:
- 5.1.2