Spring MVC Configuration Concepts
In this section, we will review some core concepts related to configuring the Spring Web MVC Framework.
DispatcherServlet (part of the org.springframework.web.servlet package) is the entry point to the world of Spring Web MVC, as depicted in Figure 7.2. It essentially dispatches requests to the controllers. If you have worked with Java web applications before, you will not be surprised to find out that this class is configured in the web.xml file, as shown in the following excerpt from the complete web.xml for Time Expression:
We will discuss DispatcherServlet in detail later in this chapter.
You can map handlers for incoming HTTP requests in the Spring application context file.These handlers are typically controllers that are mapped to partial or complete URLs of incoming requests.The handler mappings can also contain optional interceptors, which are invoked before and after the handler.This is a powerful concept. I will demonstrate an example of this later in this chapter when we use such a web interceptor for authentication and close our Hibernate session for the given HTTP request.
The following code excerpt taken from our complete timex-servlet.xml file shows how a handler can be mapped to a partial URL:
Spring uses the notion of view resolvers, which resolve view names to the actual views (enterhours to enterhours.jsp, for example).We will use Spring’s InternalResourceViewResolver class to resolve our view names. (This is covered in the next section.)