What is Spring MVC?

Spring MVC is the web framework module within the Spring ecosystem that implements the Model-View-Controller pattern to build web applications and RESTful services.

Key Points: • Model represents application data, View is responsible for rendering it, and Controller contains the request-handling logic connecting the two. • DispatcherServlet acts as the front controller, receiving every request and delegating it to the appropriate handler method. • Annotations like @Controller, @RequestMapping, and @GetMapping declaratively map URLs to Java methods. • Built-in support for data binding, validation, and view resolution reduces the boilerplate needed to handle typical web request/response cycles. • Spring MVC integrates cleanly with the rest of Spring — dependency injection, security, and data access — so web-layer code stays consistent with the rest of the application.

Example: A simple controller method annotated @GetMapping("/hello") that returns a greeting string demonstrates the core flow: DispatcherServlet routes the request to that method, the method returns data or a view name, and Spring handles turning that into an HTTP response.

Interview Tip: A concise interview answer is:

"Spring MVC is Spring's web framework built around the Model-View-Controller pattern. DispatcherServlet acts as a front controller that routes incoming requests to annotated controller methods, which work with the model and return a view name or data, and Spring resolves that into the actual HTTP response."