public class ViewResolutionResultHandler extends ContentNegotiatingResultHandlerSupport implements HandlerResultHandler, Ordered
HandlerResultHandler that encapsulates the view resolution algorithm
supporting the following return types:
View
Model
Map
@ModelAttribute
Non-simple return types are
treated as a model attribute
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 while others may interpret the same otherwise
based on annotations (e.g. for @ResponseBody).
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| Constructor and Description |
|---|
ViewResolutionResultHandler(List<ViewResolver> resolvers,
RequestedContentTypeResolver contentTypeResolver)
Constructor with
ViewResolvers and a RequestedContentTypeResolver. |
ViewResolutionResultHandler(List<ViewResolver> resolvers,
RequestedContentTypeResolver contentTypeResolver,
ReactiveAdapterRegistry adapterRegistry)
Constructor with
ViewResolvers tand a ConversionService. |
| Modifier and Type | Method and Description |
|---|---|
protected String |
getDefaultViewName(HandlerResult result,
ServerWebExchange exchange)
Translate the given request into a default view name.
|
List<View> |
getDefaultViews()
Return the configured default
View's. |
List<ViewResolver> |
getViewResolvers()
Return a read-only list of view resolvers.
|
reactor.core.publisher.Mono<Void> |
handleResult(ServerWebExchange exchange,
HandlerResult result)
Process the given result modifying response headers and/or writing data
to the response.
|
void |
setDefaultViews(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. |
getAdapterRegistry, getContentTypeResolver, getOrder, selectMediaType, setOrderpublic ViewResolutionResultHandler(List<ViewResolver> resolvers, RequestedContentTypeResolver contentTypeResolver)
ViewResolvers and a RequestedContentTypeResolver.resolvers - the resolver to usecontentTypeResolver - for resolving the requested content typepublic ViewResolutionResultHandler(List<ViewResolver> resolvers, RequestedContentTypeResolver contentTypeResolver, ReactiveAdapterRegistry adapterRegistry)
ViewResolvers tand a ConversionService.resolvers - the resolver to usecontentTypeResolver - for resolving the requested content typeadapterRegistry - for adapting from other reactive types (e.g.
rx.Single) to Monopublic List<ViewResolver> getViewResolvers()
public void setDefaultViews(List<View> defaultViews)
public boolean supports(HandlerResult result)
HandlerResultHandlerHandlerResult.supports in interface HandlerResultHandlerresult - result object to checkpublic reactor.core.publisher.Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result)
HandlerResultHandlerhandleResult in interface HandlerResultHandlerexchange - current server exchangeresult - the result from the handlingMono<Void> to indicate when request handling is complete.protected String getDefaultViewName(HandlerResult result, ServerWebExchange exchange)
The default implementation strips the leading and trailing slash from the as well as any extension and uses that as the view name.
null is returned
processing will result in an IllegalStateException.