Top Description Fields Constructors Methods
org.springframework.web.servlet.mvc

public Class ParameterizableViewController

extends AbstractController
Class Inheritance
Imports
jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.springframework.http.HttpMethod, .HttpStatus, .HttpStatusCode, org.springframework.lang.Nullable, org.springframework.web.servlet.ModelAndView, .View, org.springframework.web.servlet.support.RequestContextUtils

Trivial controller that always returns a pre-configured view and optionally sets the response status code. The view and status can be configured using the provided configuration properties.
Authors
Rod Johnson, Juergen Hoeller, Keith Donald, Rossen Stoyanchev

Field Summary

Modifier and TypeField and Description
private HttpStatusCode
private boolean
private Object

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String
public HttpStatusCode
getStatusCode()

Return the configured HTTP status code or null.

public View
getView()

Return the View object, or null if we are using a view name to be resolved by the DispatcherServlet via a ViewResolver.

public String
getViewName()

Return the name of the view to delegate to, or null if using a View instance.

protected ModelAndView
handleRequestInternal(HttpServletRequest request, HttpServletResponse response)

Implements abstract org.springframework.web.servlet.mvc.AbstractController.handleRequestInternal.

Return a ModelAndView object with the specified view name.

public boolean
isStatusOnly()

Whether the request is fully handled within the controller.

public void
setStatusCode(HttpStatusCode statusCode)

Configure the HTTP status code that this controller should set on the response.

public void
setStatusOnly(boolean statusOnly)

The property can be used to indicate the request is considered fully handled within the controller and that no view should be used for rendering.

public void
setView(View view)

Set a View object for the ModelAndView to return.

public void
setViewName(String viewName)

Set a view name for the ModelAndView to return, to be resolved by the DispatcherServlet via a ViewResolver.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.springframework.web.servlet.mvc.AbstractController:
handleRequestisSynchronizeOnSessionsetSynchronizeOnSession

Field Detail

statusCodeback to summary
private HttpStatusCode statusCode
Annotations
@Nullable
statusOnlyback to summary
private boolean statusOnly
viewback to summary
private Object view
Annotations
@Nullable

Constructor Detail

ParameterizableViewControllerback to summary
public ParameterizableViewController()

Method Detail

formatStatusAndViewback to summary
private String formatStatusAndView()
getStatusCodeback to summary
public HttpStatusCode getStatusCode()

Return the configured HTTP status code or null.

Annotations
@Nullable
Since
4.1
getViewback to summary
public View getView()

Return the View object, or null if we are using a view name to be resolved by the DispatcherServlet via a ViewResolver.

Annotations
@Nullable
Since
4.1
getViewNameback to summary
public String getViewName()

Return the name of the view to delegate to, or null if using a View instance.

Annotations
@Nullable
handleRequestInternalback to summary
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception

Implements abstract org.springframework.web.servlet.mvc.AbstractController.handleRequestInternal.

Return a ModelAndView object with the specified view name.

The content of the "input" FlashMap is also added to the model.

Annotations
@Override
See Also
getViewName()
isStatusOnlyback to summary
public boolean isStatusOnly()

Whether the request is fully handled within the controller.

setStatusCodeback to summary
public void setStatusCode(HttpStatusCode statusCode)

Configure the HTTP status code that this controller should set on the response.

When a "redirect:" prefixed view name is configured, there is no need to set this property since RedirectView will do that. However this property may still be used to override the 3xx status code of RedirectView. For full control over redirecting provide a RedirectView instance.

If the status code is 204 and no view is configured, the request is fully handled within the controller.

Since
4.1
setStatusOnlyback to summary
public void setStatusOnly(boolean statusOnly)

The property can be used to indicate the request is considered fully handled within the controller and that no view should be used for rendering. Useful in combination with setStatusCode.

By default this is set to false.

Since
4.1
setViewback to summary
public void setView(View view)

Set a View object for the ModelAndView to return. Will override any pre-existing view name or View.

Since
4.1
setViewNameback to summary
public void setViewName(String viewName)

Set a view name for the ModelAndView to return, to be resolved by the DispatcherServlet via a ViewResolver. Will override any pre-existing view name or View.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override