Spring MVC follows the Model-View-Controller pattern, and its request-handling flow is built around five core components that work together: DispatcherServlet, Controller, Model, View, and ViewResolver. Understanding how they connect explains the whole request lifecycle.
Key Points: • DispatcherServlet is the front controller that receives every incoming HTTP request and coordinates the rest of the flow. • Controller classes (or handler methods) contain the application logic that processes a request. • The Model carries data from the controller to the view, typically as a Map-like object passed alongside the view name. • View is responsible for rendering that data, e.g. as HTML via JSP or Thymeleaf. • ViewResolver maps a logical view name returned by a controller to an actual View implementation.
Example: When a browser requests /products, DispatcherServlet routes it to ProductController, which loads data into the Model and returns the view name "productList"; ViewResolver then maps that name to /WEB-INF/views/productList.jsp, which renders the final HTML.
Interview Tip: A concise interview answer is:
"The core components are DispatcherServlet as the front controller, Controllers that hold the request-handling logic, the Model that carries data, and View plus ViewResolver that turn a logical view name into rendered output. DispatcherServlet ties all of these together for every request."