What is the Use of ContextLoaderListener in Spring ?

in web.xml:

 
 org.springframework.web.context.ContextLoaderListener
 



 applicationContext.xml

This is used for bootstrap the startup – shutdown the spring application.we can define the configuration details and load it during the application startup and save it as context so we can use that configuration in overall application .

For Example :

Database Configuration

Context is always one for an application. There is no need to do configuration for ContextLoaderListener in Spring 3.0.Application will successfully run without to define it. But If we need to define some configuration into the context and that should be loaded during application start so we have to defined it in deployment descriptor

source : http://www.aoiblog.com/spring-contextloaderlistener/

* Testing in Spring 3.1 , adding ContextLoaderListener to the deployment descriptor(web.xml) without context-param and param-value, cause java.io.FileNotFoundException of the applicationContext.xml. So they must be added together.

0 comments:

Post a Comment