One, Web. XML classpath: And classpath*: What's the difference?
Classpath: Only look for files in your class path;
Classpath*: Includes not only the class path, but also the jar file (the class path) to find.
Second, storage location:
1:SRC below
It needs to be defined in Web. Xml as follows:
| 1234 |
<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value>< /context-param> |
2:web-inf below
It needs to be defined in Web. Xml as follows:
| 1234 |
<context-param><param-name>contextConfigLocation</param-name><param-value>WEB-INF/applicationContext*.xml</param-value>< /context-param> |
3. The contextconfiglocation parameter defines the Spring configuration file to be loaded.
The first spring-related configuration file must start with "applicationcontext-", conforming to the idea that the contract is better than the configuration, which is much better in terms of efficiency and error rates.
It is also best to put all the spring configuration files in a unified directory, if the project is large, you can also sub-module to build the directory. The program does not look very messy.
The configuration in Web. XML is as follows:
XML code
| 1234 |
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:**/applicationContext-*.xml</param-value> </context-param> |
"**/" means any directory;
"**/applicationcontext-*.xml" represents an XML file that begins with "applicationcontext-" in any directory.
From for notes (Wiz)
Where to configure the Applicationcontext.xml configuration file in Web. xml