public class HttpMessageWriterView extends Object implements View
View
that writes model attribute(s) with an HttpMessageWriter
.Constructor and Description |
---|
HttpMessageWriterView(Encoder<?> encoder)
Constructor with an
Encoder . |
HttpMessageWriterView(HttpMessageWriter<?> writer)
Constructor with a fully initialized
HttpMessageWriter . |
Modifier and Type | Method and Description |
---|---|
HttpMessageWriter<?> |
getMessageWriter()
Return the configured message writer.
|
Set<String> |
getModelKeys()
Return the configured model keys.
|
List<MediaType> |
getSupportedMediaTypes()
Return the list of media types this View supports, or an empty list.
|
reactor.core.publisher.Mono<Void> |
render(Map<String,?> model,
MediaType contentType,
ServerWebExchange exchange)
Render the view based on the given
HandlerResult . |
void |
setModelKeys(Set<String> modelKeys)
Set the attributes in the model that should be rendered by this view.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isRedirectView
public HttpMessageWriterView(Encoder<?> encoder)
Encoder
.public HttpMessageWriterView(HttpMessageWriter<?> writer)
HttpMessageWriter
.public HttpMessageWriter<?> getMessageWriter()
public List<MediaType> getSupportedMediaTypes()
The implementation of this method for HttpMessageWriterView
delegates to HttpMessageWriter.getWritableMediaTypes()
.
getSupportedMediaTypes
in interface View
public void setModelKeys(@Nullable Set<String> modelKeys)
HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType)
.
The matching attributes are processed as follows:
Map
, write all matches;
otherwise raise an IllegalStateException
.
public reactor.core.publisher.Mono<Void> render(@Nullable Map<String,?> model, @Nullable MediaType contentType, ServerWebExchange exchange)
View
HandlerResult
. Implementations
can access and use the model or only a specific attribute in it.render
in interface View
model
- Map with name Strings as keys and corresponding model
objects as values (Map can also be null
in case of empty model)contentType
- the content type selected to render with which should
match one of the supported media types
.exchange
- the current exchangeMono
to represent when and if rendering succeeds