Let's take a step back from this spectacular new "Hello World" and try to understand what happened inside our web application. To do this, we will retrace the journey of the HTTP request our browser sent and the response it got from the server.
The entry point of every Spring web application is the DispatcherServlet
. The following figure illustrates the Dispatcher Servlet architecture:
This is a classical HttpServlet
class that dispatches HTTP requests to HandlerMapping. A HandlerMapping is an association of resources (URLs) and Controllers.
The appropriate methods—those annotated with @RequestMapping
annotation—are then called on the Controller. In this method, the controller sets the model data and returns the view name to the dispatcher.
The DispatcherServlet
will then interrogate the ViewResolver
interface to find the corresponding implementation of the view.
In our case, the ThymeleafAutoConfiguration
class has set up the view resolver for us.
You...