Reputation: 7652
I am reallty curious about this.
Where is this "classpath*" declaration?
Follow is normaly descripted in web.xml.
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:egovframework/springmvc/context-*.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
I thought this framwork read web.xml first. However how can it knows this keyword "classpath*:" ?
Thanks for your anwer in advance:D
Upvotes: 2
Views: 5898
Reputation: 131
To give you some color, the servlet container will read the web.xml. That's what'll load the Spring Dispatcher Servlet and pass those parameters into them. Spring can read and interpret the string classpath*:egovframework/springmvc/context-*.xml to be able to locate the appropriate context files.
Upvotes: 0
Reputation: 68715
I believe spring docs describe class path resources well:
ClassPathResource
This class represents a resource which should be obtained from the classpath. This uses either the thread context class loader, a given class loader, or a given class for loading resources.
This Resource implementation supports resolution as java.io.File if the class path resource resides in the file system, but not for classpath resources which reside in a jar and have not been expanded (by the servlet engine, or whatever the environment is) to the filesystem. To address this the various Resource implementations always support resolution as a java.net.URL.
A ClassPathResource is created by Java code explicitly using the ClassPathResource constructor, but will often be created implicitly when you call an API method which takes a String argument which is meant to represent a path. For the latter case, a JavaBeans PropertyEditor will recognize the special prefix classpath:on the string path, and create a ClassPathResource in that case
Upvotes: 3