Spring Framework

Spring Projects

Spring Project 1

adplus-dvertising
Configuration of ContextLoderListener
Previous Home Next

The ContextLoderListener provide the facility to configure all spring configuration file(s) to load.This information are writen in the web.xml file which are store in the WEB -INF folder of web application directery structure, in the web.xml file following type you are configure the ContextLoaderListener:

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

And you are give the spring configuration file(s) information which are followint type configure:

<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
/WEB-INF/dispatcher-servlet.xml
/WEB-INF/data-servlet.xml
/WEB-INF/info-servlet.xml
</param-value>
</context-param>

Both listener-class and param-name all are configure following:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

<display-name>SpringMVC</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.
ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Previous Home Next