Monday, July 9, 2012

Explain Root Web Application Context in Spring MVC?

ROOT WEB APPLICATION CONTEXT XML
The root web application context XML file is associated with the portlet application. The
web application context XML file for a portlet contains portlet-specific beans, whereas
the root web application context XML file contains beans that are accessible to all
portlets in the portlet application. A bean defined in the root web application context
XML can be overridden by the portlet-specific application context XML file by defining
a bean with the same bean ID.
The portlet-specific web application context will implicitly inherit beans from the
root web application context. By default, the root web application context XML file is
defined with the name applicationContext.xml, and it must be located in the WEB-INF
directory. The root web application context XML file is loaded by the ContextLoader-
Listener object, which is configured in the portlet application’s web.xml file, as
shown here:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
If you want to name your root web application context XML file differently or store it
in a different location than the WEB-INF directory, you can specify the location of the
root web application context XML file by using the contextConfigLocation context
initialization parameter:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context/applicationContext.xml</param-value>
</context-param>


NOTE 

The contextConfigLocation portlet-initialization parameter is used
to specify a custom name or location for the web application context XML file
used by DispatcherPortlet. The contextConfigLocation context-initialization
parameter is used to specify a custom name or location for the root web
application context XML file.

No comments:

Post a Comment