public class HttpMessageWriterView extends Object implements View
View that delegates to an HttpMessageWriter.| Constructor and Description |
|---|
HttpMessageWriterView(Encoder<?> encoder)
|
HttpMessageWriterView(HttpMessageWriter<?> messageWriter)
Create a View that delegates to the given message messageWriter.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
extractObjectToRender(HandlerResult result) |
HttpMessageWriter<?> |
getMessageWriter()
Return the configured message messageWriter.
|
Set<String> |
getModelKeys()
Return the configured model keys.
|
List<MediaType> |
getSupportedMediaTypes()
Return the list of media types this View supports, or an empty list.
|
protected boolean |
isEligibleAttribute(String attributeName,
Object attributeValue)
Whether the given model attribute key-value pair is eligible for encoding.
|
reactor.core.publisher.Mono<Void> |
render(HandlerResult result,
MediaType contentType,
ServerWebExchange exchange)
Render the view based on the given
HandlerResult. |
void |
setModelKeys(Set<String> modelKeys)
By default model attributes are filtered with
HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType) to find the ones that can be
rendered. |
public HttpMessageWriterView(Encoder<?> encoder)
public HttpMessageWriterView(HttpMessageWriter<?> messageWriter)
public HttpMessageWriter<?> getMessageWriter()
public void setModelKeys(Set<String> modelKeys)
HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType) to find the ones that can be
rendered. Use this property to further narrow the list and consider only
attribute(s) under specific model key(s).
If more than one matching attribute is found, than a Map is rendered,
or if the Encoder does not support rendering a Map then
an exception is raised.
public List<MediaType> getSupportedMediaTypes()
ViewgetSupportedMediaTypes in interface Viewpublic reactor.core.publisher.Mono<Void> render(HandlerResult result, MediaType contentType, ServerWebExchange exchange)
ViewHandlerResult. Implementations
can access and use the model or only a specific attribute in it.render in interface Viewresult - the result from handler executioncontentType - 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 succeedsprotected Object extractObjectToRender(HandlerResult result)
protected boolean isEligibleAttribute(String attributeName, Object attributeValue)
The default implementation checks against the configured
model keys and whether the Encoder supports the
value type.