Modify the configuration file path using spring mvc

Source: Internet
Author: User

Modify the configuration file path using spring mvc
1.1. Classpath

Project catalog


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + 1Np3ZWIueG1szsS8/sjnz8LF5NbDo7o8L3A + Cjx0YWJsZSBib3JkZXI9 "1" cellspacing = "0" cellpadding = "0">

Spring

Org. springframework. web. servlet. DispatcherServlet

ContextConfigLocation

Classpath: config/spring-servlet.xml

1

Spring

*. Do

1.2. Classpath *

The project directory is the same as above

The following configurations are available in the Web. xml file:

Spring

Org. springframework. web. servlet. DispatcherServlet

ContextConfigLocation

Classpath*: ConfigSpring-servlet.xml

1

Spring

*. Do

1.3. What is Classpath?

The purpose of setting Classpath is to tell the Java execution environment under which directories the classes or packages required for the Java program to be executed can be found..

Classpath refers to the classes directory under the WEB-INF folder, when the web application is published to the server, all the class files and resource files under the src directory are put into the classes directory under the WEB-INF folder.

1.4. Differences between Classpath and classpath *

Classpath: searches for files in your class path only.

Classpath *: contains not only the class path, but also the jar file (class path) for search.

1) The former will only be loaded from the first classpath, while the latter will be loaded from all classpath.

2) If the resource to be loaded is not in the path of the current ClassLoader, The classpath: prefix cannot be found. In this case, you need to use classpath *: prefix.

3) if resources with the same name exist in multiple classpath and all resources need to be loaded, use classpath: only the first resource will be loaded. In this case, use classpath *: prefix.

4) use classpath *: You need to traverse all the classpath, so the loading speed is very slow. Therefore, you should plan the path of the resource file as much as possible during planning, avoid classpath * whenever possible *.

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.