CHAPTER 5: Building Java Web Applications with Spring Web MVC 229
Listing 5-31. Configuring ContextLoaderListener in web.xml
org.springframework.web.context.ContextLoaderListener
By default, ContextLoaderListener loads the application context file stored in your WEB-INF directory.
This location can be overridden by defining the contextConfigLocation context parameter in
web.xml, as shown in Listing 5-32.
Listing 5-32. File Locations Using the contextConfigLocation Parameter
classpath:service-context.xml
classpath:data-access-context.xml
At this point, the configuration of WebApplicationContext in web.xml looks like Listing 5-33.
Listing 5-33. Web.xml with ContextLoaderListener and contextConfigLocation
classpath:service-context.xml
classpath:data-access-context.xml
org.springframework.web.context.ContextLoaderListener
Note ContextLoaderListener by default looks for a /WEB-INF/applicationContext.xml file if
you do not specify a <context-param> named contextConfigLocation.
Now that you know how to configure WebApplicationContext in a web application, we can move on
to the second object, DispatcherServlet, that is configured in the web.xml file.