public class ViewResolutionResultHandler extends HandlerResultHandlerSupport implements HandlerResultHandler, Ordered
HandlerResultHandler
that encapsulates the view resolution algorithm
supporting the following return types:
Void
or no value -- default view nameString
-- view name unless @ModelAttribute
-annotated
View
-- View to render with
Model
-- attributes to add to the model
Map
-- attributes to add to the model
@ModelAttribute
-- attribute for the model
A String-based view name is resolved through the configured
ViewResolver
instances into a View
to use for rendering.
If a view is left unspecified (e.g. by returning null
or a
model-related return value), a default view name is selected.
By default this resolver is ordered at Ordered.LOWEST_PRECEDENCE
and generally needs to be late in the order since it interprets any String
return value as a view name or any non-simple value type as a model attribute
while other result handlers may interpret the same otherwise based on the
presence of annotations, e.g. for @ResponseBody
.
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
ViewResolutionResultHandler(java.util.List<ViewResolver> viewResolvers,
RequestedContentTypeResolver contentTypeResolver)
Basic constructor with a default
ReactiveAdapterRegistry . |
ViewResolutionResultHandler(java.util.List<ViewResolver> viewResolvers,
RequestedContentTypeResolver contentTypeResolver,
ReactiveAdapterRegistry registry)
Constructor with an
ReactiveAdapterRegistry instance. |
Modifier and Type | Method and Description |
---|---|
java.util.List<View> |
getDefaultViews()
Return the configured default
View 's. |
java.util.List<ViewResolver> |
getViewResolvers()
Return a read-only list of view resolvers.
|
reactor.core.publisher.Mono<java.lang.Void> |
handleResult(ServerWebExchange exchange,
HandlerResult result)
Process the given result modifying response headers and/or writing data
to the response.
|
void |
setDefaultViews(java.util.List<View> defaultViews)
Set the default views to consider always when resolving view names and
trying to satisfy the best matching content type.
|
boolean |
supports(HandlerResult result)
Whether this handler supports the given
HandlerResult . |
getAdapter, getAdapterRegistry, getContentTypeResolver, getOrder, selectMediaType, setOrder
public ViewResolutionResultHandler(java.util.List<ViewResolver> viewResolvers, RequestedContentTypeResolver contentTypeResolver)
ReactiveAdapterRegistry
.viewResolvers
- the resolver to usecontentTypeResolver
- to determine the requested content typepublic ViewResolutionResultHandler(java.util.List<ViewResolver> viewResolvers, RequestedContentTypeResolver contentTypeResolver, ReactiveAdapterRegistry registry)
ReactiveAdapterRegistry
instance.viewResolvers
- the view resolver to usecontentTypeResolver
- to determine the requested content typeregistry
- for adaptation to reactive typespublic java.util.List<ViewResolver> getViewResolvers()
public void setDefaultViews(@Nullable java.util.List<View> defaultViews)
public java.util.List<View> getDefaultViews()
View
's.public boolean supports(HandlerResult result)
HandlerResultHandler
HandlerResult
.supports
in interface HandlerResultHandler
result
- result object to checkpublic reactor.core.publisher.Mono<java.lang.Void> handleResult(ServerWebExchange exchange, HandlerResult result)
HandlerResultHandler
handleResult
in interface HandlerResultHandler
exchange
- current server exchangeresult
- the result from the handlingMono<Void>
to indicate when request handling is complete.