类 HandlerResult
- java.lang.Object
- org.springframework.web.reactive.HandlerResult
public class HandlerResult extends Object
Represent the result of the invocation of a handler or a handler method.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 HandlerResult(Object handler, Object returnValue, MethodParameter returnType)Create a newHandlerResult.HandlerResult(Object handler, Object returnValue, MethodParameter returnType, BindingContext context)Create a newHandlerResult.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<HandlerResult>applyExceptionHandler(Throwable failure)Apply the exception handler and return the alternative result.BindingContextgetBindingContext()Return the BindingContext used for request handling.ObjectgetHandler()Return the handler that handled the request.ModelgetModel()Return the model used for request handling.ResolvableTypegetReturnType()Return the type of the value returned from the handler -- e.g. the return type declared on a controller method's signature.MethodParametergetReturnTypeSource()Return theMethodParameterfrom whichreturnTypewas created.ObjectgetReturnValue()Return the value returned from the handler, if any.booleanhasExceptionHandler()Whether there is an exception handler.HandlerResultsetExceptionHandler(Function<Throwable,reactor.core.publisher.Mono<HandlerResult>> function)Configure an exception handler that may be used to produce an alternative result when result handling fails.
构造器详细资料
HandlerResult
public HandlerResult(Object handler, @Nullable Object returnValue, MethodParameter returnType)
Create a newHandlerResult.- 参数:
handler- the handler that handled the requestreturnValue- the return value from the handler possiblynullreturnType- the return value type
HandlerResult
public HandlerResult(Object handler, @Nullable Object returnValue, MethodParameter returnType, @Nullable BindingContext context)
Create a newHandlerResult.- 参数:
handler- the handler that handled the requestreturnValue- the return value from the handler possiblynullreturnType- the return value typecontext- the binding context used for request handling
方法详细资料
getHandler
public Object getHandler()
Return the handler that handled the request.
getReturnValue
@Nullable public Object getReturnValue()
Return the value returned from the handler, if any.
getReturnType
public ResolvableType getReturnType()
Return the type of the value returned from the handler -- e.g. the return type declared on a controller method's signature. Also seegetReturnTypeSource()to obtain the underlyingMethodParameterfor the return type.
getReturnTypeSource
public MethodParameter getReturnTypeSource()
Return theMethodParameterfrom whichreturnTypewas created.
getBindingContext
public BindingContext getBindingContext()
Return the BindingContext used for request handling.
getModel
public Model getModel()
Return the model used for request handling. This is a shortcut forgetBindingContext().getModel().
setExceptionHandler
public HandlerResult setExceptionHandler(Function<Throwable,reactor.core.publisher.Mono<HandlerResult>> function)
Configure an exception handler that may be used to produce an alternative result when result handling fails. Especially for an async return value errors may occur after the invocation of the handler.- 参数:
function- the error handler- 返回:
- the current instance
hasExceptionHandler
public boolean hasExceptionHandler()
Whether there is an exception handler.
applyExceptionHandler
public reactor.core.publisher.Mono<HandlerResult> applyExceptionHandler(Throwable failure)
Apply the exception handler and return the alternative result.- 参数:
failure- the exception- 返回:
- the new result or the same error if there is no exception handler