public class HttpMessageWriterView extends java.lang.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.
|
java.util.Set<java.lang.String> |
getModelKeys()
Return the configured model keys.
|
java.util.List<MediaType> |
getSupportedMediaTypes()
Return the list of media types this View supports, or an empty list.
|
reactor.core.publisher.Mono<java.lang.Void> |
render(java.util.Map<java.lang.String,?> model,
MediaType contentType,
ServerWebExchange exchange)
Render the view based on the given
HandlerResult . |
void |
setModelKeys(java.util.Set<java.lang.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 java.util.List<MediaType> getSupportedMediaTypes()
The implementation of this method for HttpMessageWriterView
delegates to HttpMessageWriter.getWritableMediaTypes()
.
getSupportedMediaTypes
in interface View
public void setModelKeys(@Nullable java.util.Set<java.lang.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 final java.util.Set<java.lang.String> getModelKeys()
public reactor.core.publisher.Mono<java.lang.Void> render(@Nullable java.util.Map<java.lang.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
- a 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