Creating a Spring MVC web controller
Assuming we have unzipped that ZIP file from the Spring Initializr and imported it into our IDE, we can immediately start writing a web controller.
But for starters, what is a web controller?
Web controllers are bits of code that respond to HTTP requests. These can comprise an HTTP GET
/
request that is asking for the root URL. Most websites respond with some HTML. But web controllers can also answer requests for APIs that yield JavaScript Object Notation (JSON), such as HTTP GET /api/videos
. Furthermore, web controllers do the heavy lifting of transporting provided JSON when the user is affecting change with an HTTP POST
.
The piece of the Spring portfolio that affords us the ability to write web controllers is Spring MVC. Spring MVC is Spring Frameworkâs module that lets us build web apps on top of servlet-based containers using the Model-View-Controller (MVC) paradigm.
Yes, the application we are building is Spring Boot. But...