类 HttpMessageWriterView
- java.lang.Object
- org.springframework.web.reactive.result.view.HttpMessageWriterView
- 所有已实现的接口:
View
public class HttpMessageWriterView extends Object implements View
View
that writes model attribute(s) with anHttpMessageWriter
.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
字段概要
从接口继承的字段 org.springframework.web.reactive.result.view.View
BINDING_CONTEXT_ATTRIBUTE
构造器概要
构造器 构造器 说明 HttpMessageWriterView(Encoder<?> encoder)
Constructor with anEncoder
.HttpMessageWriterView(HttpMessageWriter<?> writer)
Constructor with a fully initializedHttpMessageWriter
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 givenHandlerResult
.void
setModelKeys(Set<String> modelKeys)
Set the attributes in the model that should be rendered by this view.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.reactive.result.view.View
isRedirectView
构造器详细资料
HttpMessageWriterView
public HttpMessageWriterView(Encoder<?> encoder)
Constructor with anEncoder
.
HttpMessageWriterView
public HttpMessageWriterView(HttpMessageWriter<?> writer)
Constructor with a fully initializedHttpMessageWriter
.
方法详细资料
getMessageWriter
public HttpMessageWriter<?> getMessageWriter()
Return the configured message writer.
getSupportedMediaTypes
public List<MediaType> getSupportedMediaTypes()
Return the list of media types this View supports, or an empty list.The implementation of this method for
HttpMessageWriterView
delegates toHttpMessageWriter.getWritableMediaTypes()
.- 指定者:
getSupportedMediaTypes
在接口中View
setModelKeys
public void setModelKeys(@Nullable Set<String> modelKeys)
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 withHttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType)
. 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 anIllegalStateException
.
getModelKeys
public final Set<String> getModelKeys()
Return the configured model keys.
render
public reactor.core.publisher.Mono<Void> render(@Nullable Map<String,?> model, @Nullable MediaType contentType, ServerWebExchange exchange)
从接口复制的说明:View
Render the view based on the givenHandlerResult
. Implementations can access and use the model or only a specific attribute in it.- 指定者:
render
在接口中View
- 参数:
model
- a Map with name Strings as keys and corresponding model objects as values (Map can also benull
in case of empty model)contentType
- the content type selected to render with which should match one of thesupported media types
.exchange
- the current exchange- 返回:
Mono
to represent when and if rendering succeeds