Interface View
- All Known Implementing Classes:
AbstractUrlBasedView,AbstractView,FreeMarkerView,HttpMessageWriterView,RedirectView,ScriptTemplateView
public interface View
Contract to renderHandlerResultto the HTTP response.In contrast to an
Encoderwhich is a singleton and encodes any object of a given type, aViewis typically selected by name and resolved using aViewResolverwhich may for example match it to an HTML template. Furthermore aViewmay render based on multiple attributes contained in the model.A
Viewcan also choose to select an attribute from the model use any existingEncoderto render alternate media types.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
Field Summary
Fields Modifier and Type Field Description static StringBINDING_CONTEXT_ATTRIBUTEThe name of the exchange attribute that contains theBindingContextfor the request which can be used to createBindingResultinstances for objects in to the model.
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default List<MediaType>getSupportedMediaTypes()Return the list of media types this View supports, or an empty list.default booleanisRedirectView()Whether this View does rendering by performing a redirect.reactor.core.publisher.Mono<Void>render(Map<String,?> model, MediaType contentType, ServerWebExchange exchange)Render the view based on the givenHandlerResult.
Field Detail
BINDING_CONTEXT_ATTRIBUTE
static final String BINDING_CONTEXT_ATTRIBUTE
The name of the exchange attribute that contains theBindingContextfor the request which can be used to createBindingResultinstances for objects in to the model.Note: This attribute is not required and may not be present.
- Since:
- 5.1.8
Method Detail
getSupportedMediaTypes
default List<MediaType> getSupportedMediaTypes()
Return the list of media types this View supports, or an empty list.
isRedirectView
default boolean isRedirectView()
Whether this View does rendering by performing a redirect.
render
reactor.core.publisher.Mono<Void> render(@Nullable Map<String,?> model, @Nullable MediaType contentType, ServerWebExchange exchange)
Render the view based on the givenHandlerResult. Implementations can access and use the model or only a specific attribute in it.- Parameters:
model- a Map with name Strings as keys and corresponding model objects as values (Map can also benullin case of empty model)contentType- the content type selected to render with which should match one of thesupported media types.exchange- the current exchange- Returns:
Monoto represent when and if rendering succeeds