Introduction to Controllers

Get introduced to the concept of controllers in Spring MVC.

What are controllers?

In an MVC framework, a controller receives data (the input) via the view. It then processes the received data with the help of the model, and finally returns the processed data (the output) back to the view.

Controllers in Spring MVC are the glue between the view (which are Thymeleaf templates in our case) and the business logic.

Controllers in Spring

Spring uses the @Controller annotation to mark a class as being a controller. This is an example controller:

Get hands-on with 1400+ tech skills courses.