Skip to content
Model centric tools for Spring development Community portal
Skyway PerspectivesModel driven delivery

Model reference

Reference Figure: Request Flow in MVC

A step by step view of a single request as it moves from the browser through the controller, service and data layers and back to a rendered page.

Diagram of the model view controller pattern with a request moving from the browser to the controller, service and data layers
Figure 7. The request flow is the same for every generated screen.

Every screen in a generated application follows the same request flow. Once the flow is familiar, a new screen is easy to trace: find the mapping, follow the service call, then read the view.

The flow in order

  • Dispatch. The servlet dispatcher receives the request and looks up a handler.
  • Bind. Request parameters are bound to method arguments or to a form object.
  • Validate. A validator checks the bound object and records any errors.
  • Call. The controller calls one service operation with the validated input.
  • Render. The controller returns a view name and the view resolver renders the page.

Redirect after post

Write operations end with a redirect rather than a direct render. A redirect prevents a browser refresh from repeating the write. The generated create and edit actions follow this rule, and the flash attributes carry the success message across the redirect.

Debugging tip. If a page renders without data, check the model attribute name first. A mismatch between the name added in the controller and the name read in the view is the most common cause.

The flow figure is also useful when reviewing a pull request. Trace one request end to end and confirm that each layer has a single, clear responsibility.