public interface Rendering
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 | Interface and Description |
---|---|
static interface |
Rendering.Builder<B extends Rendering.Builder<B>>
Defines a builder for
Rendering . |
static interface |
Rendering.RedirectBuilder
Extends
Rendering.Builder with extra options for redirect scenarios. |
Modifier and Type | Method and Description |
---|---|
HttpHeaders |
headers()
Return headers to add to the response.
|
java.util.Map<java.lang.String,java.lang.Object> |
modelAttributes()
Return attributes to add to the model.
|
static Rendering.RedirectBuilder |
redirectTo(java.lang.String url)
Create a new builder for a redirect through a
RedirectView . |
HttpStatus |
status()
Return the HTTP status to set the response to.
|
java.lang.Object |
view()
Return the selected
String view name or View object. |
static Rendering.Builder<?> |
view(java.lang.String name)
Create a new builder for response rendering based on the given view name.
|
java.util.Map<java.lang.String,java.lang.Object> modelAttributes()
@Nullable HttpStatus status()
HttpHeaders headers()
static Rendering.Builder<?> view(java.lang.String name)
name
- the view name to be resolved to a View
static Rendering.RedirectBuilder redirectTo(java.lang.String url)
RedirectView
.url
- the redirect URL