Top Description Fields Methods
org.springframework.web.reactive.result.view

public Interface View

Known Direct Implementers
org.springframework.web.reactive.result.view.AbstractView, org.springframework.web.reactive.result.view.HttpMessageWriterView
Imports
java.util.Collections, .List, .Map, reactor.core.publisher.Mono, org.springframework.http.MediaType, org.springframework.lang.Nullable, org.springframework.web.reactive.HandlerResult, org.springframework.web.server.ServerWebExchange

Contract to render HandlerResult to the HTTP response.

In contrast to an Encoder which is a singleton and encodes any object of a given type, a View is typically selected by name and resolved using a ViewResolver which may for example match it to an HTML template. Furthermore a View may render based on multiple attributes contained in the model.

A View can also choose to select an attribute from the model use any existing Encoder to render alternate media types.

Author
Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
public static final String
BINDING_CONTEXT_ATTRIBUTE

The name of the exchange attribute that contains the BindingContext for the request which can be used to create BindingResult instances for objects in to the model.

Method Summary

Modifier and TypeMethod and Description
public default List<MediaType>
getSupportedMediaTypes()

Return the list of media types this View supports, or an empty list.

public default boolean
isRedirectView()

Whether this View does render by performing a redirect.

public Mono<Void>

Returns:

Mono to represent when and if rendering succeeds
render
(Map<String, ?>
a Map with name Strings as keys and corresponding model objects as values (Map can also be null in case of empty model)
model
,
MediaType
the content type selected to render with which should match one of the supported media types.
contentType
,
ServerWebExchange
the current exchange
exchange
)

Render the view based on the given HandlerResult.

Field Detail

BINDING_CONTEXT_ATTRIBUTEback to summary
public static final String BINDING_CONTEXT_ATTRIBUTE

The name of the exchange attribute that contains the BindingContext for the request which can be used to create BindingResult instances for objects in to the model.

Note

This attribute is not required and may not be present.

Since
5.1.8

Method Detail

getSupportedMediaTypesback to summary
public default List<MediaType> getSupportedMediaTypes()

Return the list of media types this View supports, or an empty list.

isRedirectViewback to summary
public default boolean isRedirectView()

Whether this View does render by performing a redirect.

renderback to summary
public Mono<Void> render(Map<String, ?> model, MediaType contentType, ServerWebExchange exchange)

Render the view based on the given HandlerResult. Implementations can access and use the model or only a specific attribute in it.

Parameters
model:Map<String, ?>

a Map with name Strings as keys and corresponding model objects as values (Map can also be null in case of empty model)

contentType:MediaType

the content type selected to render with which should match one of the supported media types.

exchange:ServerWebExchange

the current exchange

Returns:Mono<Void>

Mono to represent when and if rendering succeeds