public class ServletInvocableHandlerMethod extends InvocableHandlerMethod
InvocableHandlerMethod
with the ability to handle the value returned from the method through
a registered HandlerMethodArgumentResolver
that supports the given return value type.
Return value handling may include writing to the response or updating the ModelAndViewContainer
structure.
If the underlying method has a ResponseStatus
instruction, the status on the response is set
accordingly after the method is invoked but before the return value is handled.
invokeAndHandle(NativeWebRequest, ModelAndViewContainer, Object...)
logger
Constructor and Description |
---|
ServletInvocableHandlerMethod(Object handler,
Method method)
Creates a
ServletInvocableHandlerMethod instance with the given bean and method. |
Modifier and Type | Method and Description |
---|---|
void |
invokeAndHandle(NativeWebRequest request,
ModelAndViewContainer mavContainer,
Object... providedArgs)
Invokes the method and handles the return value through a registered
HandlerMethodReturnValueHandler . |
void |
setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers) |
getDetailedErrorMessage, invokeForRequest, setDataBinderFactory, setHandlerMethodArgumentResolvers, setParameterNameDiscoverer
createWithResolvedBean, equals, getBean, getBeanType, getBridgedMethod, getMethod, getMethodAnnotation, getMethodParameters, getReturnType, hashCode, isVoid, toString
public ServletInvocableHandlerMethod(Object handler, Method method)
ServletInvocableHandlerMethod
instance with the given bean and method.handler
- the object handlermethod
- the methodpublic void setHandlerMethodReturnValueHandlers(HandlerMethodReturnValueHandlerComposite returnValueHandlers)
public final void invokeAndHandle(NativeWebRequest request, ModelAndViewContainer mavContainer, Object... providedArgs) throws Exception
HandlerMethodReturnValueHandler
.
Return value handling may be skipped entirely when the method returns null
(also possibly due
to a void
return type) and one of the following additional conditions is true:
HandlerMethodArgumentResolver
has set the ModelAndViewContainer.setRequestHandled(boolean)
flag to false
-- e.g. method arguments providing access to the response.
ServletWebRequest.checkNotModified(long)
and ServletWebRequest.checkNotModified(String)
. In this case a response with "not modified" response
headers will be automatically generated without the need for return value handling.
ResponseStatus
instruction.
After the return value is handled, callers of this method can use the ModelAndViewContainer
to gain access to model attributes, view selection choices, and to check if view resolution is even needed.
request
- the current requestmavContainer
- the ModelAndViewContainer
for the current requestprovidedArgs
- argument values to try to use without the need for view resolutionException
Copyright © 2013. All Rights Reserved.