Interface ServerResponse.BodyBuilder
- All Superinterfaces:
ServerResponse.HeadersBuilder<ServerResponse.BodyBuilder>
- Enclosing interface:
- ServerResponse
public static interface ServerResponse.BodyBuilder
extends ServerResponse.HeadersBuilder<ServerResponse.BodyBuilder>
Defines a builder that adds a body to the response.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.web.servlet.function.ServerResponse.HeadersBuilder
ServerResponse.HeadersBuilder.WriteFunction
-
Method Summary
Modifier and TypeMethodDescriptionSet 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.contentLength
(long contentLength) Set the length of the body in bytes, as specified by theContent-Length
header.contentType
(MediaType contentType) Set the media type of the body, as specified by theContent-Type
header.Render the template with the givenname
using the givenmodelAttributes
.Render the template with the givenname
using the givenmodel
.Methods inherited from interface org.springframework.web.servlet.function.ServerResponse.HeadersBuilder
allow, allow, build, build, cacheControl, cookie, cookies, eTag, header, headers, lastModified, lastModified, location, varyBy
-
Method Details
-
contentLength
Set the length of the body in bytes, as specified by theContent-Length
header.- Parameters:
contentLength
- the content length- Returns:
- this builder
- See Also:
-
contentType
Set the media type of the body, as specified by theContent-Type
header.- Parameters:
contentType
- the content type- Returns:
- this builder
- See Also:
-
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 (or any asynchronous producer of a single entity that can be adapted via theReactiveAdapterRegistry
).- Parameters:
body
- the body of the response- Returns:
- the built response
-
body
Set the body of the response to the givenObject
and return it. The parameterbodyType
is used to capture the generic type.- Parameters:
body
- the body of the responsebodyType
- the type of the body, used to capture the generic type- Returns:
- the built response
-
render
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.- Parameters:
name
- the name of the template to be renderedmodelAttributes
- the modelAttributes used to render the template- Returns:
- the built response
-
render
Render the template with the givenname
using the givenmodel
.- Parameters:
name
- the name of the template to be renderedmodel
- the model used to render the template- Returns:
- the built response
-