DispatcherServlet
Spring uses a Front Controller like many of the other leading MVC architectures. The Front Controller in Spring is called DispatcherServlet and is declared in the web.xml file. In this example, Spring sets up the following declaration for the DispatcherServlet:
<servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
The file includes a basic reference to the servlet class and the configuration file for the servlet located in the /WEB-INF/spring/appServlet/ folder. Unlike other MVC architectures, Spring's dispatcher servlet has full access to the container (i.e., the Spring container)
The servlet-context.xml file contains the Bean properties for the beans that Spring uses to resolve view, locale, theme, and multi-part file resolvers. Most of the time, these beans and their properties are pre-configured for you with the necessary values.