|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.web.servlet.mvc.method.annotation.support.DefaultMethodReturnValueHandler
public class DefaultMethodReturnValueHandler
Attempts to handle return value types not recognized by any other HandlerMethodReturnValueHandler.
Intended to be used as the last of a list of registered handlers as supportsReturnType(MethodParameter)
always returns true.
Handling takes place in the following order:
ModelAndViewResolvers provided to the constructor of this class looking
for a return value that isn't ModelAndViewResolver.UNRESOLVED.
Note that ModelAndViewResolver is supported for backwards compatibility. Since the only way to check
if it supports a return value type is to try to resolve the return value, a ModelAndViewResolver can
only be invoked from here after no other HandlerMethodReturnValueHandler has recognized the return
value. To avoid this limitation change the ModelAndViewResolver to implement
HandlerMethodReturnValueHandler instead.
| Constructor Summary | |
|---|---|
DefaultMethodReturnValueHandler()
Create a DefaultMethodReturnValueHandler instance without ModelAndViewResolvers. |
|
DefaultMethodReturnValueHandler(List<ModelAndViewResolver> mavResolvers)
Create a DefaultMethodReturnValueHandler with a list of ModelAndViewResolvers. |
|
| Method Summary | |
|---|---|
void |
handleReturnValue(Object returnValue,
MethodParameter returnType,
ModelAndViewContainer mavContainer,
NativeWebRequest request)
Handle the given return value by adding attributes to the model, setting the view (or view name), or by writing to the response. |
boolean |
supportsReturnType(MethodParameter returnType)
Whether the given method return type is supported by this handler. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultMethodReturnValueHandler()
DefaultMethodReturnValueHandler instance without ModelAndViewResolvers.
public DefaultMethodReturnValueHandler(List<ModelAndViewResolver> mavResolvers)
DefaultMethodReturnValueHandler with a list of ModelAndViewResolvers.
| Method Detail |
|---|
public boolean supportsReturnType(MethodParameter returnType)
HandlerMethodReturnValueHandler
supportsReturnType in interface HandlerMethodReturnValueHandlerreturnType - the method return type to check
true if this handler supports the supplied return type; false otherwise
public void handleReturnValue(Object returnValue,
MethodParameter returnType,
ModelAndViewContainer mavContainer,
NativeWebRequest request)
throws Exception
HandlerMethodReturnValueHandlerHandlerMethodReturnValueHandler implementations should also
consider whether to set ModelAndViewContainer.setResolveView(boolean), which is set to
true by default and therefore needs to be set to false explicitly if view
resolution is to be bypassed.
handleReturnValue in interface HandlerMethodReturnValueHandlerreturnValue - the value returned from the handler methodreturnType - the type of the return value. This type must have previously been passed to
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter) and it must have returned truemavContainer - the ModelAndViewContainer for the current requestrequest - the current request
Exception - if the return value handling results in an error
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||