Top Description Inners Methods
org.springframework.web.reactive.result.view

public Interface Rendering

Known Direct Implementers
org.springframework.web.reactive.result.view.DefaultRendering
Imports
java.util.Collection, .Map, org.springframework.http.HttpHeaders, .HttpStatusCode, org.springframework.lang.Nullable, org.springframework.ui.Model

Public API for HTML rendering. Supported as a return value in Spring WebFlux controllers. Comparable to the use of ModelAndView as a return value in Spring MVC controllers.

Controllers typically return a String view name and rely on the "implicit" model which can also be injected into the controller method. Or controllers may return model attribute(s) and rely on a default view name being selected based on the request path.

Rendering can be used to combine a view name with model attributes, set the HTTP status or headers, and for other more advanced options around redirect scenarios.

Author
Rossen Stoyanchev
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Rendering.Builder<
a self reference to the builder type
B extends Rendering.Builder<B>
>

Defines a builder for Rendering.

public static interface
Rendering.RedirectBuilder

Extends Builder with extra options for redirect scenarios.

Method Summary

Modifier and TypeMethod and Description
public HttpHeaders
headers()

Return headers to add to the response.

public Map<String, Object>
modelAttributes()

Return attributes to add to the model.

public static Rendering.RedirectBuilder

Returns:

the builder
redirectTo
(String
the redirect URL
url
)

Create a new builder for a redirect through a RedirectView.

public HttpStatusCode
status()

Return the HTTP status to set the response to.

public Object
view()

Return the selected String view name or View object.

public static Rendering.Builder<?>

Returns:

the builder
view
(String
the view name to be resolved to a View
name
)

Create a new builder for response rendering based on the given view name.

Method Detail

headersback to summary
public HttpHeaders headers()

Return headers to add to the response.

modelAttributesback to summary
public Map<String, Object> modelAttributes()

Return attributes to add to the model.

redirectToback to summary
public static Rendering.RedirectBuilder redirectTo(String url)

Create a new builder for a redirect through a RedirectView.

Parameters
url:String

the redirect URL

Returns:Rendering.RedirectBuilder

the builder

statusback to summary
public HttpStatusCode status()

Return the HTTP status to set the response to.

Annotations
@Nullable
viewback to summary
public Object view()

Return the selected String view name or View object.

Annotations
@Nullable
viewback to summary
public static Rendering.Builder<?> view(String name)

Create a new builder for response rendering based on the given view name.

Parameters
name:String

the view name to be resolved to a View

Returns:Rendering.Builder<?>

the builder

org.springframework.web.reactive.result.view back to summary

public Interface Rendering.Builder<B extends Rendering.Builder<B>>

Known Direct Subinterfaces
org.springframework.web.reactive.result.view.Rendering.RedirectBuilder
Type Parameters
<B>
a self reference to the builder type

Defines a builder for Rendering.

Method Summary

Modifier and TypeMethod and Description
public Rendering
build()

Build the Rendering instance.

public B
header(String headerName, String... headerValues)

Specify a header to add to the response.

public B
headers(HttpHeaders headers)

Specify headers to add to the response.

public B
model(Map<String, ?> map)

Add the given attributes to the model.

public B
modelAttribute(String name, Object value)

Add the given model attribute with the supplied name.

public B
modelAttribute(Object value)

Add an attribute to the model using a generated name.

public B
modelAttributes(Object... values)

Add all given attributes to the model using generated names.

public B
status(HttpStatusCode status)

Specify the status to use for the response.

Method Detail

buildback to summary
public Rendering build()

Build the Rendering instance.

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

Specify a header to add to the response.

headersback to summary
public B headers(HttpHeaders headers)

Specify headers to add to the response.

modelback to summary
public B model(Map<String, ?> map)

Add the given attributes to the model.

See Also
Model#addAllAttributes(Map)
modelAttributeback to summary
public B modelAttribute(String name, Object value)

Add the given model attribute with the supplied name.

See Also
Model#addAttribute(String, Object)
modelAttributeback to summary
public B modelAttribute(Object value)

Add an attribute to the model using a generated name.

See Also
Model#addAttribute(Object)
modelAttributesback to summary
public B modelAttributes(Object... values)

Add all given attributes to the model using generated names.

See Also
Model#addAllAttributes(Collection)
statusback to summary
public B status(HttpStatusCode status)

Specify the status to use for the response.

org.springframework.web.reactive.result.view back to summary

public Interface Rendering.RedirectBuilder

extends Rendering.Builder<Rendering.RedirectBuilder>
Known Direct Implementers
org.springframework.web.reactive.result.view.DefaultRenderingBuilder

Extends Builder with extra options for redirect scenarios.

Method Summary

Modifier and TypeMethod and Description
public Rendering.RedirectBuilder
contextRelative(boolean contextRelative)

Whether to the provided redirect URL should be prepended with the application context path (if any).

public Rendering.RedirectBuilder
propagateQuery(boolean propagate)

Whether to append the query string of the current URL to the target redirect URL or not.

Inherited from org.springframework.web.reactive.result.view.Rendering.Builder:
buildheaderheadersmodelmodelAttributemodelAttributemodelAttributesstatus

Method Detail

contextRelativeback to summary
public Rendering.RedirectBuilder contextRelative(boolean contextRelative)

Whether to the provided redirect URL should be prepended with the application context path (if any).

By default this is set to true.

See Also
RedirectView#setContextRelative(boolean)
propagateQueryback to summary
public Rendering.RedirectBuilder propagateQuery(boolean propagate)

Whether to append the query string of the current URL to the target redirect URL or not.

By default this is set to false.

See Also
RedirectView#setPropagateQuery(boolean)