Creating the Spring MVC Controller

We will now create the Controller class. In Spring MVC, the Controller is mapped to the request URL and handles requests matching the URL pattern. The request URL for matching an incoming request is specified at the method level in the controller. However, more generic request mapping can be specified at the Controller class level, and a specific URL, with respect to the URL at the class level, can be specified at the method level.

Create a class named CourseController in the packt.jee.course_management.controller package. Annotate it with @Controller. The @Controller annotation is of type @Component, and allows the Spring Framework to identify that class specifically as a controller. Add the method to get ...

Get Java EE 8 Development with Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.