1.1. Classpath
Project folder
In the Web. xml file such as the following configuration:
<!-- Configure the core servlet of springMVC -- < servlet > < Servlet-name >Spring</servlet-name> < Servlet-class >org.springframework.web.servlet.DispatcherServlet</servlet-class> < Init-param > < Param-name >contextconfiglocation</param-name> <!-- Specify the path to the springMVC configuration file/web-inf/<[servlet-name]-servlet.xml> like this here for/web-inf/ Spring-servlet.xml The following configuration is also the default value-- <param-value>classpath:config/spring-servlet.xml</param-value> </ Init-param > <!-- The configuration starts with the server itself proactively initialized -- < Load-on-startup >1</load-on-startup> </ servlet > < servlet-mapping > < Servlet-name >Spring</servlet-name> <!-- filter all suffixes named. Do requests-- < Url-pattern >*.do</url-pattern> </ servlet-mapping > |
1.2. classpath*
The project folder is the same as above
The Web. xml file is configured for example:
<!-- Configure the core servlet of springMVC -- < servlet > < Servlet-name >Spring</servlet-name> < Servlet-class >org.springframework.web.servlet.DispatcherServlet</servlet-class> < Init-param > < Param-name >contextconfiglocation</param-name> <!-- Specify the path to the springMVC configuration file/web-inf/<[servlet-name]-servlet.xml> like this here for/web-inf/ Spring-servlet.xml The following configuration is also the default value-- <param-value>classpath*:config/spring-servlet.xml</param-value> </ Init-param > <!-- The configuration starts with the server itself proactively initialized -- < Load-on-startup >1</load-on-startup> </ servlet > < servlet-mapping > < Servlet-name >Spring</servlet-name> <!-- filter all suffixes named. Do requests-- < Url-pattern >*.do</url-pattern> </ servlet-mapping > |
1.3. What is Classpath?
Set Classpath the purpose. is to tell the java Runtime which folders are able to find The classes or packages that you need to run the Java program .
Classpath refers to the classes folder under the Web-inf folder. When the Web app is advertised to the server, the compiled class and resource files for all of the classes under the SRC folder are placed into the Classes folder under the Web-inf folder.
1.4. The difference between classpath and classpath*
Classpath: Just look for the file in your class path.
Classpath*: Includes not only the class path. Also included in the jar file (class path) to find.
1) The former will only be loaded from the first classpath, and the latter will be loaded from all classpath.
2) Assume the resource to be loaded. Not in the current ClassLoader path, then the classpath: prefix is not found, in this case you need to use the classpath*: prefix.
3) in multiple classpath with the same name of the resource, all need to load, then use CLASSPATH: Only load the first, in this case also need to use classpath*: prefix.
4) Use classpath*: Need to traverse all classpath. So the loading speed is very slow, so when planning, you should plan the path of the resource file as well as possible. Try to avoid using classpath*.
Spring MVC churn configuration file path