SPRING CONCEPTS

Trace a Spring MVC request

Spring Concepts / Detailed guide

Browser → Security filters → DispatcherServlet → Controller → Service → Repository → Atlas

For GET /todos, Tomcat accepts the HTTP request. Security filters apply their rules. DispatcherServlet locates the mapped controller method. The controller requests a list from the service, which uses the repository to read MongoDB documents. The controller places that list in Model and returns "list". Thymeleaf resolves templates/list.html and renders HTML. The response goes back to the browser.

For a JSON endpoint, the same route ends with the controller returning an object. A message converter serializes it to JSON. @RequestBody performs the reverse operation: JSON becomes the request DTO before your method executes.

Keep responsibilities clear: controllers handle HTTP and view/API contracts, services implement operations and authorization rules, repositories access documents, DTOs define accepted inputs, and templates/components present results.

← All Spring Concepts · Learning path

Java 21 · Spring Boot 4.1.1 · Edupoly