Controller

A Controller is the component that contains Navigation logic. Navigation logic are also referred as Control logic. Controllers in Spring MVC are defined by @Controller annotation.

The Controller is responsible to receive and process user request, create and prepare Model object with data required by View, and transfer control to View for rendering.

The Controller is mapped with URL with the help of @RequestMapping annotation. Annotation @RequestMapping can map Controller class and its methods as well.

Here is a sample example that maps a controller to /Welcome url.