Where to configure the Applicationcontext.xml configuration file in Web. xml

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.