8.3.1 Resource实现类------ClassPathResource : 访问类加载路径下的资源的实现类

        2.访问类加载路径下的资源

          ClassPathResource 用来访问类加载路径下的资源,相对于其他的Resource实现类,其主要优势是方便访问类加载路径下的资源,尤其对于Web应用,ClassPathResource可自动搜索位于WEB-INF/classes下的资源文件,无须使用绝对路径访问。

        /*创建一个Resource对象,从类加载路径下读取资源*/
ClassPathResource cpr = new ClassPathResource("book.xml");

          ClassPathResource实例可使用ClassPathResource构造器显式地创建,但更多的时候它都是隐式地创建的。当执行Spring的某个方法时,该方法接受一个代表资源路径的字符串参数,当Spring识别该字符串参数中包含classpath:前缀后,系统会自动创建ClassPathResource对象。

啦啦啦

8 -- 深入使用Spring -- 3...1 Resource实现类ClassPathResource的更多相关文章

  1. 8 -- 深入使用Spring -- 3...1 Resource实现类InputStreamResource、ByteArrayResource

    8.3.1 Resource实现类------InputStreamResource:访问输入流资源的实现类.ByteArrayResource:访问字节数组资源的实现类. 5. 访问字节数组资源 ⊙ ...

  2. 8 -- 深入使用Spring -- 3...1 Resource实现类ServletContextResource

    8.3.1 Resource实现类------ServletContextResource:访问相对于ServletContext路径下的资源的实现类. 4.访问应用相关资源 Spring提供了Ser ...

  3. 8 -- 深入使用Spring -- 3...1 Resource实现类FileSystemResource

    8.3.1 Resource实现类------FileSystemResource:访问文件系统的资源的实现类 3.访问文件系统资源 Spring提供的FileSystemResource类用于访问文 ...

  4. 8 -- 深入使用Spring -- 3...1 Resource实现类

    8.3.1 Resource实现类 Resource接口是Spring资源访问的接口,具体的资源访问由该接口的实现类完成. Spring提供的Resource接口的实现类: ⊙ UrlResource ...

  5. 8 -- 深入使用Spring -- 3...1 Resource实现类UrlResource

    8.3.1 Resource 实现类------UrlResource : 访问网络资源的实现类 1.访问网络资源 访问网络资源通过UrlResource 类实现,UrlResource是java.n ...

  6. Spring Injection with @Resource, @Autowired and @Inject

    August 1st, 2011 by David Kessler Overview I’ve been asked several times to explain the difference b ...

  7. Spring JTA multiple resource transactions in Tomcat with Atomikos example

    http://www.byteslounge.com/tutorials/spring-jta-multiple-resource-transactions-in-tomcat-with-atomik ...

  8. 使用import简化spring的配置 spring import 标签的解析 使用import或加载spring配置时,报错误There is no ID/IDREF 多个Spring配置文件import resource路径配置

    spring-import 标签的解析.使用案例: 对于spring配置文件的编写,我想,对于经历过庞大项目的人,都有那种恐惧的心理,太多的配置文件.不过,分模块都是大多数人能想到的方法,但是,怎么分 ...

  9. 170324、Spring 处理器和Resource

    1.Spring 框架允许开发者使用两种后处理器扩展 IoC 容器,这两种后处理器扩展 IoC 容器,这两种后处理器可以后处理 IoC 容器本身,或对容器中所有的 Bean 进行后处理.IoC 容器还 ...

随机推荐

  1. sudo开发常用命令总结

    ansible ws -m "shell" -a "echo 'wangsong ALL=(ALL) NOPASSWD: /usr/local/bin/superviso ...

  2. JAVASCRIPT 之escape 介绍

    escape() 方法:采用ISO Latin字符集对指定的字符串进行编码.所有的空格符.标点符号.特殊字符以及其他非ASCII字 符都将被转化成%xx格式的字符编码(xx等于该字符在字符集表里面的编 ...

  3. Python 类的初见

    #定义一个Python类 class Cat: #self关键字相当于c++类中的this指针 def eat(self): print("i am eating .") def ...

  4. 自然语言交流系统 phxnet团队 创新实训 项目博客 (三)

    语音转文本部分是调用的科大讯飞的在线语音,它的激发方式是按键,通过按钮触发开启安卓设备的录音,此部分需要在源码中写入关于安卓权限的要求,来调用安卓的录音权限,当按钮被激发,则开始进入语音录制阶段,将麦 ...

  5. GENA

    GENA这是事件消息采用格式,是所谓“普通事件通知体系Generic Event Notification Architecture”的缩写

  6. TP Rate ,FP Rate, Precision, Recall, F-Measure, ROC Area,

    TP Rate ,FP Rate, Precision, Recall, F-Measure, ROC Area, https://www.zhihu.com/question/30643044 T/ ...

  7. 【转】Graphics.DrawCurve的算法

    public static class Spline { [System.Diagnostics.DebuggerDisplay("({X},{Y})")] public part ...

  8. Luhn算法检验和验证

    一.Luhn公式介绍 Luhn公式是一种广泛使用的系统,用于对标识号进行验证.它根据原始标识号,把每隔一个数字的值扩大一倍.然后把各个单独数字的值加在一起(如果扩大一倍后的值为2个数字,就把这两个数字 ...

  9. vi 命令集

    一:跳到文件第一行 1. 输入:0或:1,然后回车: 2. 在键盘按下小写gg:   二:跳到文件最后一行 1. 输入:$,然后回车: 2. 在键盘按下大写G : 3. 在键盘按Shift + g: ...

  10. e742. 加入标签的可拖动能力

    This example demonstrates how to modify a label component so that its text can be dragged and droppe ...