1, contextConfigLocation parameters defined in web.xml .spring uses this parameter to load all comma-separated xml. Without this parameter, spring loaded by default web-inf / applicationContext.xml file
<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:conf/spring/applicationContext_core*.xml, classpath*:conf/spring/applicationContext_dict*.xml, classpath*:conf/spring/applicationContext_hibernate.xml, classpath*:conf/spring/applicationContext_staff*.xml, classpath*:conf/spring/applicationContext_security.xml classpath*:conf/spring/applicationContext_modules*.xml classpath*:conf/spring/applicationContext_cti*.xml classpath*:conf/spring/applicationContext_apm*.xml </param-value> </context-param>
contextConfigLocation parameter defines Spring configuration file to be loaded. Principle as follows:
using ServletContextListener achieve.
Spring provides an implementation class ServletContextListener ContextLoaderListener, the class can be made
for the listener to use, it will automatically find applicationContext.xrnl file WEB-INF / under at the time of creation. Because of
this, if there is only one configuration file, and the file name applicationContext.xml, you only need to web.xml
add the following code to the file:
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
If multiple configuration files need to load, consider using <context-para i.e. profile element to determine
the file name. Since ContextLoaderListener loaded, it looks for a parameter called contextConfigLocation.
Therefore, when configuring context-param parameter name should be contextConfigLocation.
Web.xml file with the plurality of configuration file
< ! - file header XML file -> <xml Version? = "LO" encoding = "work 80-8859-1" ? > < ! - DTD file information such as web.xm1 -> ! <DOCTYPE Web-App the PUBLIC "-. // Sun Microsystems ual the Application Web 2.3 // EN c.//DTD" '' HTTP: //java.sun .com / DTD / Web-app_2_3.dtd '' > < Web-App > <-! determining a plurality of profiles -> < context-param > < ! - parameter named ... contextConfigLocation -> <param-name > contextConfigLocation </ param-name > <!> /WEB-INF/daoContext.xml, /WEB-INF/applicationContext.xml </ param-value > </ context-param > <-! Employed listener created Applicat station onContext Examples -> < listener > < listener- class > org.spr station ngframework.web.context.ContextLoader The listener </ listener-class > </ listener > </ Web-App >