Repaso
EspaƱol
Spring, JPA & Java WebIntermediateSPR-26

How does a request flow through Spring MVC?

Options

  1. The browser calls the controller method straight away
  2. DispatcherServlet maps the request to a controller (Correct option)
  3. The database receives the request first and forwards it
  4. The request is stored in a queue and processed later

Answer

The embedded server (Tomcat) receives it, the DispatcherServlet (front controller) maps it to a controller method, which calls services; the result is converted to JSON and returned

Why

  1. The embedded servlet container (Tomcat) receives the HTTP request.
  2. Filters run (security, logging).
  3. The DispatcherServlet is the single entry point: it finds which controller method handles that URL and HTTP method.
  4. Arguments are resolved (@PathVariable, @RequestBody via Jackson) and the controller runs, calling services and repositories.
  5. The return value is converted (usually to JSON) and written to the response; exceptions go to @ControllerAdvice.

Remember

Tomcat, filters, DispatcherServlet, controller, service, repository.

Key terms

Practice this question in Repaso