类 HandlerMethodReturnValueHandlerComposite
- java.lang.Object
- org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite
- 所有已实现的接口:
HandlerMethodReturnValueHandler
public class HandlerMethodReturnValueHandlerComposite extends Object implements HandlerMethodReturnValueHandler
Handles method return values by delegating to a list of registeredHandlerMethodReturnValueHandlers
. Previously resolved return types are cached for faster lookups.- 从以下版本开始:
- 3.1
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 HandlerMethodReturnValueHandlerComposite()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 HandlerMethodReturnValueHandlerComposite
addHandler(HandlerMethodReturnValueHandler handler)
Add the givenHandlerMethodReturnValueHandler
.HandlerMethodReturnValueHandlerComposite
addHandlers(List<? extends HandlerMethodReturnValueHandler> handlers)
Add the givenHandlerMethodReturnValueHandlers
.List<HandlerMethodReturnValueHandler>
getHandlers()
Return a read-only list with the registered handlers, or an empty list.void
handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
Iterate over registeredHandlerMethodReturnValueHandlers
and invoke the one that supports it.boolean
supportsReturnType(MethodParameter returnType)
Whether the given method return type is supported by any registeredHandlerMethodReturnValueHandler
.
构造器详细资料
HandlerMethodReturnValueHandlerComposite
public HandlerMethodReturnValueHandlerComposite()
方法详细资料
getHandlers
public List<HandlerMethodReturnValueHandler> getHandlers()
Return a read-only list with the registered handlers, or an empty list.
supportsReturnType
public boolean supportsReturnType(MethodParameter returnType)
Whether the given method return type is supported by any registeredHandlerMethodReturnValueHandler
.- 指定者:
supportsReturnType
在接口中HandlerMethodReturnValueHandler
- 参数:
returnType
- the method return type to check- 返回:
true
if this handler supports the supplied return type;false
otherwise
handleReturnValue
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception
Iterate over registeredHandlerMethodReturnValueHandlers
and invoke the one that supports it.- 指定者:
handleReturnValue
在接口中HandlerMethodReturnValueHandler
- 参数:
returnValue
- the value returned from the handler methodreturnType
- the type of the return value. This type must have previously been passed toHandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
which must have returnedtrue
.mavContainer
- the ModelAndViewContainer for the current requestwebRequest
- the current request- 抛出:
IllegalStateException
- if no suitableHandlerMethodReturnValueHandler
is found.Exception
- if the return value handling results in an error
addHandler
public HandlerMethodReturnValueHandlerComposite addHandler(HandlerMethodReturnValueHandler handler)
Add the givenHandlerMethodReturnValueHandler
.
addHandlers
public HandlerMethodReturnValueHandlerComposite addHandlers(@Nullable List<? extends HandlerMethodReturnValueHandler> handlers)
Add the givenHandlerMethodReturnValueHandlers
.