From the course: Spring: Spring MVC
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Add controllers and test the application
From the course: Spring: Spring MVC
Add controllers and test the application
- [Instructor] Now that we have all the necessary configuration in place, let's go ahead and add a basic HomeController class. So on the IDE, right-click again on com.test, create a class, and let's say HomeController, that's the name. Now this is the first controller that we're writing as a part of the Spring MVC project. Now in order to designate this as controller, we will have to annotate it appropriately. The annotation for that is Controller. So Spring MVC will then know that this is a controller component. Now this controller component is supposed to be intercepting some HTTP request, and that request should have a unique URL pattern which is going to be unique to the HomeController. Now that URL pattern can be defined with another annotation, which is called GetMapping. So for this GetMapping, you can just specify an argument with the help of brackets, and say /home. Now for this /home pattern, we're supposed to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Why use Spring MVC?3m 42s
-
(Locked)
Features of Spring MVC3m 40s
-
(Locked)
Spring MVC architecture2m 7s
-
(Locked)
Create Maven Spring MVC project3m 25s
-
(Locked)
Add folders and static files2m 27s
-
(Locked)
Java configuration for Spring MVC10m 9s
-
(Locked)
Add controllers and test the application4m 59s
-
(Locked)
Generate Spring MVC project with Spring Boot5m 13s
-
(Locked)
Add static files and view resolver5m 3s
-
(Locked)
Add controllers and test the application7m 14s
-
(Locked)
-
-
-
-
-
-
-
-