Applicationcontext.xml file location can have two default implementations

Source: Internet
Author: User

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

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.