Top Description Inners Methods
org.springframework.web.servlet.function

public Interface RenderingResponse

extends ServerResponse
Known Direct Implementers
org.springframework.web.servlet.function.DefaultRenderingResponseBuilder.DefaultRenderingResponse
Imports
java.util.Collection, .Map, java.util.function.Consumer, jakarta.servlet.http.Cookie, org.springframework.http.HttpHeaders, .HttpStatusCode, org.springframework.lang.Nullable, org.springframework.util.MultiValueMap

Rendering-specific subtype of ServerResponse that exposes model and template data.
Author
Arjen Poutsma
Since
5.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RenderingResponse.Builder

Defines a builder for RenderingResponse.

Method Summary

Modifier and TypeMethod and Description
public static RenderingResponse.Builder

Returns:

the created builder
create
(String
the name of the template to render
name
)

Create a builder with the given template name.

public static RenderingResponse.Builder

Returns:

the created builder
from
(RenderingResponse
the response to copy the values from
other
)

Create a builder with the template name, status code, headers and model of the given response.

public Map<String, Object>
model()

Return the unmodifiable model map.

public String
name()

Return the name of the template to be rendered.

Inherited from org.springframework.web.servlet.function.ServerResponse:
acceptedasyncasyncbadRequestcookiescreatedfromfromheadersnoContentnotFoundokpermanentRedirectrawStatusCodeseeOtherssessestatusstatusstatusCodetemporaryRedirectunprocessableEntitywriteTo

Method Detail

createback to summary
public static RenderingResponse.Builder create(String name)

Create a builder with the given template name.

Parameters
name:String

the name of the template to render

Returns:RenderingResponse.Builder

the created builder

fromback to summary
public static RenderingResponse.Builder from(RenderingResponse other)

Create a builder with the template name, status code, headers and model of the given response.

Parameters
other:RenderingResponse

the response to copy the values from

Returns:RenderingResponse.Builder

the created builder

modelback to summary
public Map<String, Object> model()

Return the unmodifiable model map.

nameback to summary
public String name()

Return the name of the template to be rendered.

org.springframework.web.servlet.function back to summary

public Interface RenderingResponse.Builder

Known Direct Implementers
org.springframework.web.servlet.function.DefaultRenderingResponseBuilder

Defines a builder for RenderingResponse.

Method Summary

Modifier and TypeMethod and Description
public RenderingResponse

Returns:

the built response
build
()

Build the response.

public RenderingResponse.Builder

Returns:

this builder
cookie
(Cookie
the cookie to add
cookie
)

Add the given cookie to the response.

public RenderingResponse.Builder

Returns:

this builder
cookies
(Consumer<MultiValueMap<String, Cookie>>
a function that consumes the cookies
cookiesConsumer
)

Manipulate this response's cookies with the given consumer.

public RenderingResponse.Builder

Returns:

this builder
header
(String
the header name
headerName
,
String...
the header value(s)
headerValues
)

Add the given header value(s) under the given name.

public RenderingResponse.Builder

Returns:

this builder
headers
(Consumer<HttpHeaders>
a function that consumes the HttpHeaders
headersConsumer
)

Manipulate this response's headers with the given consumer.

public RenderingResponse.Builder
modelAttribute(Object
the model attribute value (never null)
attribute
)

Add the supplied attribute to the model using a generated name.

public RenderingResponse.Builder
modelAttribute(String
the name of the model attribute (never null)
name
,
Object
the model attribute value (can be null)
value
)

Add the supplied attribute value under the supplied name.

public RenderingResponse.Builder
modelAttributes(Object... attributes)

Copy all attributes in the supplied array into the model, using attribute name generation for each element.

public RenderingResponse.Builder
modelAttributes(Collection<?> attributes)

Copy all attributes in the supplied Collection into the model, using attribute name generation for each element.

public RenderingResponse.Builder
modelAttributes(Map<String, ?> attributes)

Copy all attributes in the supplied Map into the model.

public RenderingResponse.Builder

Returns:

this builder
status
(HttpStatusCode
the response status
status
)

Set the HTTP status.

public RenderingResponse.Builder

Returns:

this builder
status
(int
the response status
status
)

Set the HTTP status.

Method Detail

buildback to summary
public RenderingResponse build()

Build the response.

Returns:RenderingResponse

the built response

cookieback to summary
public RenderingResponse.Builder cookie(Cookie cookie)

Add the given cookie to the response.

Parameters
cookie:Cookie

the cookie to add

Returns:RenderingResponse.Builder

this builder

cookiesback to summary
public RenderingResponse.Builder cookies(Consumer<MultiValueMap<String, Cookie>> cookiesConsumer)

Manipulate this response's cookies with the given consumer. The cookies provided to the consumer are "live", so that the consumer can be used to overwrite existing cookies, remove cookies, or use any of the other MultiValueMap methods.

Parameters
cookiesConsumer:Consumer<MultiValueMap<String, Cookie>>

a function that consumes the cookies

Returns:RenderingResponse.Builder

this builder

headerback to summary
public RenderingResponse.Builder header(String headerName, String... headerValues)

Add the given header value(s) under the given name.

Parameters
headerName:String

the header name

headerValues:String[]

the header value(s)

Returns:RenderingResponse.Builder

this builder

See Also
HttpHeaders#add(String, String)
headersback to summary
public RenderingResponse.Builder headers(Consumer<HttpHeaders> headersConsumer)

Manipulate this response's headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the other HttpHeaders methods.

Parameters
headersConsumer:Consumer<HttpHeaders>

a function that consumes the HttpHeaders

Returns:RenderingResponse.Builder

this builder

modelAttributeback to summary
public RenderingResponse.Builder modelAttribute(Object attribute)

Add the supplied attribute to the model using 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. View code should check for null rather than for empty collections.

Parameters
attribute:Object

the model attribute value (never null)

modelAttributeback to summary
public RenderingResponse.Builder modelAttribute(String name, Object value)

Add the supplied attribute value under the supplied name.

Parameters
name:String

the name of the model attribute (never null)

value:Object

the model attribute value (can be null)

modelAttributesback to summary
public RenderingResponse.Builder modelAttributes(Object... attributes)

Copy all attributes in the supplied array into the model, using attribute name generation for each element.

See Also
modelAttribute(Object)
modelAttributesback to summary
public RenderingResponse.Builder modelAttributes(Collection<?> attributes)

Copy all attributes in the supplied Collection into the model, using attribute name generation for each element.

See Also
modelAttribute(Object)
modelAttributesback to summary
public RenderingResponse.Builder modelAttributes(Map<String, ?> attributes)

Copy all attributes in the supplied Map into the model.

See Also
modelAttribute(String, Object)
statusback to summary
public RenderingResponse.Builder status(HttpStatusCode status)

Set the HTTP status.

Parameters
status:HttpStatusCode

the response status

Returns:RenderingResponse.Builder

this builder

statusback to summary
public RenderingResponse.Builder status(int status)

Set the HTTP status.

Parameters
status:int

the response status

Returns:RenderingResponse.Builder

this builder