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 *.