Spring MVC is the part of Spring used to build web applications that handle HTTP requests. It provides components that intercept and manage requests, letting application code focus on what to do with them. section 1.2 section 7.5
A Java web application also needs a servlet container, such as Tomcat, to translate HTTP requests and responses for the application. Spring Boot can configure both the container and Spring MVC components automatically. section 7.5
For a minimal request-response flow:
- Mark a controller class with @Controller. section 7.5
- Use @RequestMapping to assign a controller action to an HTTP request. section 7.5
- Provide an HTML document containing the data to send in the response. section 7.5
Spring MVC also supports REST endpoints. Use @ResponseBody when a controller method returns the response body directly, or use @RestController instead of @Controller. Without either, the dispatcher servlet treats the method’s return value as a view name and looks for that view. section 10.6
A REST endpoint can receive data through request parameters, path variables, or the request body. An action can use Spring’s default response status or return a ResponseEntity to manage the status and headers. Exceptions can be handled in the action or separately in a REST controller advice class, which can help avoid duplicated handling logic. section 10.6



