spring-framework / org.springframework.web.reactive.result.view / HttpMessageWriterView

HttpMessageWriterView

open class HttpMessageWriterView : View

View that writes model attribute(s) with an HttpMessageWriter.

Author
Rossen Stoyanchev

Since
5.0

Constructors

<init>

HttpMessageWriterView(encoder: Encoder<*>)

Constructor with an Encoder.

HttpMessageWriterView(writer: HttpMessageWriter<*>)

Constructor with a fully initialized HttpMessageWriter.

Functions

getMessageWriter

open fun getMessageWriter(): HttpMessageWriter<*>

Return the configured message writer.

getModelKeys

fun getModelKeys(): MutableSet<String>

Return the configured model keys.

getSupportedMediaTypes

open fun getSupportedMediaTypes(): MutableList<MediaType>

{@inheritDoc}

The implementation of this method for HttpMessageWriterView delegates to HttpMessageWriter#getWritableMediaTypes().

render

open fun render(model: MutableMap<String, *>, contentType: MediaType, exchange: ServerWebExchange): Mono<Void>

setModelKeys

open fun setModelKeys(modelKeys: MutableSet<String>): Unit

Set the attributes in the model that should be rendered by this view. When set, all other model attributes will be ignored. The matching attributes are further narrowed with HttpMessageWriter#canWrite. The matching attributes are processed as follows:

  • 0: nothing is written to the response body.
  • 1: the matching attribute is passed to the writer.
  • 2..N: if the writer supports Map, write all matches; otherwise raise an IllegalStateException.