From the course: Complete Guide to Spring MVC

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Controllers

Controllers

- [Instructor] Controllers. Spring MVC controllers form the foundation of handling HTTP requests in modern web applications, including implementing efficient caching strategies to improve performance. Controllers in Spring MVC handle HTTP requests and map them to methods for processing. As we've seen throughout this course, the annotations for controller include the following. One, @Controller. This defines a class as a Spring MVC controller. Or @RestController, and this combines controller with response body annotation for REST API specifically. And then you're able to map HTTP methods to controller methods by using RequestMapping, GetMapping, or PostMapping annotations. The dispatcher servlet is responsible for routing requests to the appropriate controller methods based on URL mappings. Within controllers, to improve performance, you'll want to implement HTTP caching. You can do so in a few ways, starting with conditional requests. For conditional requests, you'll want to use…

Contents