The role of Contextloaderlistener is to automatically assemble applicationcontext configuration information when the Web container is started. Because it implements the Servletcontextlistener interface, when the Web. XML configures this listener, when the container is started, it executes the method it implements by default.
If you do not write any parameter configuration information in Web. XML, the default path is /web-inf/applicationcontext.xml, and the name of the file created under the web-inf directory must be Applicationcontext.xml. If you want to customize the file name, you can add contextconfiglocation to the context parameter in Web. XML:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/web-inf/classes/applicationcontext-*.xml
</param-value>
</context-param>
In <param-value> </param-value> Specify the appropriate XML file name, if there are multiple XML files, can be written together and one "," number separated. The applicationcontext-*.xml above uses a wildcard character, For example, in this directory there are applicationcontext-ibatis-base.xml,applicationcontext-action.xml,applicationcontext-ibatis-dao.xml and other files, will be loaded together.
The applicationcontext.xml file location can have two default implementations:
The first : put it directly under /web-inf , which declares a contextloaderlistener in web. XML
The second kind : put it under classpath , but add <context-param>in Web. XML to indicate your the location of the applicationcontext.xml for the Web container to load.
Applicationcontext.xml file location can have two default implementations