The class of access resources provided by the JDK does not satisfy the access requirements of various underlying resources, so spring designs a resource interface that provides the application with more powerful access to the underlying resources.
Main methods:
Boolean exists () to determine if a resource exists
Boolean IsOpen () to determine if the resource is already open
URL GetURL () if the underlying resource can be represented as a URL, the method returns the URL object
File GetFile () if the underlying resource corresponds to a file, the method returns the corresponding Files object
InputStream getInputStream () returns the input stream corresponding to the resource
Specific implementation classes:
Bytearrayresource
Classpathresource
Filesystemresource
Inputstreamresource
Servletcontextresource
Urlresource
To access different types of resources, you must use the corresponding resource implementation class, which is cumbersome, and spring provides a powerful mechanism to load resources that automatically identify different resource types
Resource type address prefix:
Classpath loading resources from the Classpath classpath:com/jike/bean.xml
File File:/com/jike/bean.xml
HTTP/http://www.jike.com/bean.xml
FTP Ftp://www.jike.com/bean.xml
No prefix com/jike/bean.xml
Ant-Style matching characters:
? : Match one of the characters in the file name
*: matches any character in the file name
* *: Matching multi-layer paths
Examples of ant-style resource paths:
Classpath:com/t*st.xml
File:d:/conf/*.xml
Classpath:com/**/test.xml
Classpath:org/springframework/**/*.xml
Spring defines a set of interfaces for resource loading and provides an implementation class, as follows
Spring---resource access tool class