Java Reference
In-Depth Information
Listing 5-31. Configuring ContextLoaderListener in web.xml
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
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
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:service-context.xml
classpath:data-access-context.xml
</param-value>
</context-param>
At this point, the configuration of WebApplicationContext in web.xml looks like Listing 5-33.
Listing 5-33. Web.xml with ContextLoaderListener and contextConfigLocation
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:service-context.xml
classpath:data-access-context.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
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.
 
Search WWH ::




Custom Search