Top Description Fields Constructors Methods
org.springframework.web.reactive.result.method.annotation

public Class ResponseBodyResultHandler

extends AbstractMessageWriterResultHandler
implements HandlerResultHandler
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.HandlerResultHandler
Imports
java.net.URI, java.util.List, reactor.core.publisher.Mono, org.springframework.core.MethodParameter, .ReactiveAdapterRegistry, org.springframework.core.annotation.AnnotatedElementUtils, org.springframework.http.HttpStatusCode, .ProblemDetail, org.springframework.http.codec.HttpMessageWriter, org.springframework.web.bind.annotation.ResponseBody, org.springframework.web.reactive.HandlerResult, .HandlerResultHandler, org.springframework.web.reactive.accept.RequestedContentTypeResolver, org.springframework.web.server.ServerWebExchange

HandlerResultHandler that handles return values from methods annotated with @ResponseBody writing to the body of the request or response with an HttpMessageWriter.

By default the order for this result handler is set to 100. As it detects the presence of @ResponseBody it should be ordered after result handlers that look for a specific return type. Note however that this handler does recognize and explicitly ignores the ResponseEntity return type.

Authors
Rossen Stoyanchev, Stephane Maldini, Sebastien Deleuze, Arjen Poutsma
Since
5.0

Field Summary

Inherited from org.springframework.web.reactive.result.method.annotation.AbstractMessageWriterResultHandler:
COROUTINES_FLOW_CLASS_NAME

Constructor Summary

AccessConstructor and Description
public
ResponseBodyResultHandler(List<HttpMessageWriter<?>>
the writers for serializing to the response body
writers
,
RequestedContentTypeResolver
to determine the requested content type
resolver
)

Basic constructor with a default ReactiveAdapterRegistry.

public
ResponseBodyResultHandler(List<HttpMessageWriter<?>>
the writers for serializing to the response body
writers
,
RequestedContentTypeResolver
to determine the requested content type
resolver
,
ReactiveAdapterRegistry
for adaptation to reactive types
registry
)

Constructor with an ReactiveAdapterRegistry instance.

Method Summary

Modifier and TypeMethod and Description
public Mono<Void>
handleResult(ServerWebExchange
current server exchange
exchange
,
HandlerResult
the result from the handling
result
)

Implements org.springframework.web.reactive.HandlerResultHandler.handleResult.

Process the given result modifying response headers and/or writing data to the response.

public boolean
supports(HandlerResult
the result object to check
result
)

Implements org.springframework.web.reactive.HandlerResultHandler.supports.

Whether this handler supports the given HandlerResult.

Inherited from org.springframework.web.reactive.result.method.annotation.AbstractMessageWriterResultHandler:
getMessageWriterswriteBodywriteBody

Constructor Detail

ResponseBodyResultHandlerback to summary
public ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver)

Basic constructor with a default ReactiveAdapterRegistry.

Parameters
writers:List<HttpMessageWriter<?>>

the writers for serializing to the response body

resolver:RequestedContentTypeResolver

to determine the requested content type

ResponseBodyResultHandlerback to summary
public ResponseBodyResultHandler(List<HttpMessageWriter<?>> writers, RequestedContentTypeResolver resolver, ReactiveAdapterRegistry registry)

Constructor with an ReactiveAdapterRegistry instance.

Parameters
writers:List<HttpMessageWriter<?>>

the writers for serializing to the response body

resolver:RequestedContentTypeResolver

to determine the requested content type

registry:ReactiveAdapterRegistry

for adaptation to reactive types

Method Detail

handleResultback to summary
public Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result)

Implements org.springframework.web.reactive.HandlerResultHandler.handleResult.

Doc from org.springframework.web.reactive.HandlerResultHandler.handleResult.

Process the given result modifying response headers and/or writing data to the response.

Parameters
exchange:ServerWebExchange

current server exchange

result:HandlerResult

the result from the handling

Returns:Mono<Void>

Mono<Void> to indicate when request handling is complete.

Annotations
@Override
supportsback to summary
public boolean supports(HandlerResult result)

Implements org.springframework.web.reactive.HandlerResultHandler.supports.

Doc from org.springframework.web.reactive.HandlerResultHandler.supports.

Whether this handler supports the given HandlerResult.

Parameters
result:HandlerResult

the result object to check

Returns:boolean

whether this object can use the given result

Annotations
@Override