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.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Rendering.
a self reference to the builder type B extends Rendering.Defines a builder for |
| public static interface | Rendering.
Extends |
| Modifier and Type | Method and Description |
|---|---|
| public HttpHeaders | |
| public Map | |
| public static Rendering. | Returns: the builderthe redirect URL url)Create a new builder for a redirect through a |
| public HttpStatusCode | |
| public Object | |
| public static Rendering. |
| headers | back to summary |
|---|---|
| public HttpHeaders headers() Return headers to add to the response. | |
| modelAttributes | back to summary |
|---|---|
| public Map Return attributes to add to the model. | |
| redirectTo | back to summary |
|---|---|
| public static Rendering. Create a new builder for a redirect through a
| |
| status | back to summary |
|---|---|
| public HttpStatusCode status() Return the HTTP status to set the response to.
| |
| view | back to summary |
|---|---|
| public Object view() Return the selected
| |
| view | back to summary |
|---|---|
| public static Rendering. Create a new builder for response rendering based on the given view name. | |
Rendering.
| Modifier and Type | Method and Description |
|---|---|
| public Rendering | |
| public B | |
| public B | |
| public B | |
| public B | |
| public B | |
| public B | |
| public B |
| build | back to summary |
|---|---|
| public Rendering build() Build the | |
| header | back to summary |
|---|---|
| public B header(String headerName, String... headerValues) Specify a header to add to the response. | |
| headers | back to summary |
|---|---|
| public B headers(HttpHeaders headers) Specify headers to add to the response. | |
| model | back to summary |
|---|---|
| public B model(Map<String, ?> map) Add the given attributes to the model.
| |
| modelAttribute | back to summary |
|---|---|
| public B modelAttribute(String name, Object value) Add the given model attribute with the supplied name.
| |
| modelAttribute | back to summary |
|---|---|
| public B modelAttribute(Object value) Add an attribute to the model using a
| |
| modelAttributes | back to summary |
|---|---|
| public B modelAttributes(Object... values) Add all given attributes to the model using
| |
| status | back to summary |
|---|---|
| public B status(HttpStatusCode status) Specify the status to use for the response. | |
Builder with extra options for redirect scenarios.
| Modifier and Type | Method and Description |
|---|---|
| public Rendering. | contextRelative(boolean contextRelative)
Whether to the provided redirect URL should be prepended with the application context path (if any). |
| public Rendering. | propagateQuery(boolean propagate)
Whether to append the query string of the current URL to the target redirect URL or not. |
| contextRelative | back to summary |
|---|---|
| public Rendering. Whether to the provided redirect URL should be prepended with the application context path (if any). By default this is set to | |
| propagateQuery | back to summary |
|---|---|
| public Rendering. Whether to append the query string of the current URL to the target redirect URL or not. By default this is set to | |