上一节简单的介绍了一下spring中的资源体系设计,最终的抽象类型是Resource,能够获取输入流和文件信息。
这一节总结一下资源加载起ResourceLoader。
所谓资源加载器,就是把上一节讲到的Resource加载到spring中用到的工具类,在spring中被设计为ResourceLoader。
简单的看下ResourceLoader接口
/**
* Strategy interface for loading resources (e.. class path or file system
* resources).
* <p>Bean properties of type Resource and Resource array can be populated
* from Strings when running in an ApplicationContext, using the particular
* context's resource loading strategy.
*/
public interface ResourceLoader {
/** Pseudo URL prefix for loading from the class path: "classpath:" */
String CLASSPATH_URL_PREFIX = ResourceUtils.CLASSPATH_URL_PREFIX;
/**
* Return a Resource handle for the specified resource location.
* <li>Must support fully qualified URLs, e.g. "file:C:/test.dat".
* <li>Mus