接口 ServerResponse.BodyBuilder
- 封闭接口:
- ServerResponse
public static interface ServerResponse.BodyBuilder extends ServerResponse.HeadersBuilder<ServerResponse.BodyBuilder>
Defines a builder that adds a body to the response.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 ServerResponse
body(Object body)
Set the body of the response to the givenObject
and return it.<T> ServerResponse
body(T body, ParameterizedTypeReference<T> bodyType)
Set the body of the response to the givenObject
and return it.ServerResponse.BodyBuilder
contentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Length
header.ServerResponse.BodyBuilder
contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.ServerResponse
render(String name, Object... modelAttributes)
Render the template with the givenname
using the givenmodelAttributes
.ServerResponse
render(String name, Map<String,?> model)
Render the template with the givenname
using the givenmodel
.从接口继承的方法 org.springframework.web.servlet.function.ServerResponse.HeadersBuilder
allow, allow, build, build, cacheControl, cookie, cookies, eTag, header, headers, lastModified, lastModified, location, varyBy
方法详细资料
contentLength
ServerResponse.BodyBuilder contentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Length
header.- 参数:
contentLength
- the content length- 返回:
- this builder
- 另请参阅:
HttpHeaders.setContentLength(long)
contentType
ServerResponse.BodyBuilder contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.- 参数:
contentType
- the content type- 返回:
- this builder
- 另请参阅:
HttpHeaders.setContentType(MediaType)
body
ServerResponse body(Object body)
Set the body of the response to the givenObject
and return it.Asynchronous response bodies are supported by providing a
CompletionStage
orPublisher
as body.- 参数:
body
- the body of the response- 返回:
- the built response
body
<T> ServerResponse body(T body, ParameterizedTypeReference<T> bodyType)
Set the body of the response to the givenObject
and return it. The parameterbodyType
is used to capture the generic type.- 参数:
body
- the body of the responsebodyType
- the type of the body, used to capture the generic type- 返回:
- the built response
render
ServerResponse render(String name, Object... modelAttributes)
Render the template with the givenname
using the givenmodelAttributes
. The model attributes are mapped under a generated name.Note: Empty
Collections
are not added to the model when using this method because we cannot correctly determine the true convention name.- 参数:
name
- the name of the template to be renderedmodelAttributes
- the modelAttributes used to render the template- 返回:
- the built response
render
ServerResponse render(String name, Map<String,?> model)
Render the template with the givenname
using the givenmodel
.- 参数:
name
- the name of the template to be renderedmodel
- the model used to render the template- 返回:
- the built response