Spring Resources接口
来源:互联网 发布:软件测试策略 编辑:程序博客网 时间:2024/05/16 11:30
要获取Resource对象需要继承ResourceLoader接口
ApplicationContext继承了ResourceLoader接口,可以直接使用
esource template = ctx.getResource("some/resource/path/myTemplate.txt");
Table 6.1. Resource strings 的类型
classpath:
classpath:com/myapp/config.xml
Loaded from the classpath.
file:
file:///data/config.xml
Loaded as a URL
, from the filesystem. [1]
http:
http://myserver/logo.png
Loaded as a URL
.
(none)
/data/config.xml
Depends on the underlying ApplicationContext
.
[1]But see also Section 6.7.3, “FileSystemResource caveats”.
Resource template = ctx.getResource("classpath:some/resource/path/myTemplate.txt");
Resource template = ctx.getResource("file:///some/resource/path/myTemplate.txt");
Resource template = ctx.getResource("http://myhost.com/resource/path/myTemplate.txt");
获取ApplicationContext 对象可以继承 ApplicationContextAware 接口
Aware接口
public interface ApplicationContextAware { void setApplicationContext(ApplicationContext applicationContext) throws BeansException;}实现Aware接口即可在对象中使用相对应的资源,例如applicationContext.getBean("...");
Table 5.4. Aware interfaces
ApplicationContextAware
Declaring ApplicationContext
Section 5.6.2, “ApplicationContextAware and BeanNameAware”
ApplicationEventPublisherAware
Event publisher of the enclosing ApplicationContext
Section 5.15, “Additional Capabilities of the ApplicationContext”
BeanClassLoaderAware
Class loader used to load the bean classes.
Section 5.3.2, “Instantiating beans”
BeanFactoryAware
Declaring BeanFactory
Section 5.6.2, “ApplicationContextAware and BeanNameAware”
BeanNameAware
Name of the declaring bean
Section 5.6.2, “ApplicationContextAware and BeanNameAware”
BootstrapContextAware
Resource adapter BootstrapContext
the container runs in. Typically available only in JCA awareApplicationContext
s
Chapter 26,JCA CCI
LoadTimeWeaverAware
Defined weaver for processing class definition at load time
Section 9.8.4, “Load-time weaving with AspectJ in the Spring Framework”
MessageSourceAware
Configured strategy for resolving messages (with support for parametrization and internationalization)
Section 5.15, “Additional Capabilities of the ApplicationContext”
NotificationPublisherAware
Spring JMX notification publisher
Section 25.7, “Notifications”
PortletConfigAware
Current PortletConfig
the container runs in. Valid only in a web-aware SpringApplicationContext
Chapter 20,Portlet MVC Framework
PortletContextAware
Current PortletContext
the container runs in. Valid only in a web-aware SpringApplicationContext
Chapter 20,Portlet MVC Framework
ResourceLoaderAware
Configured loader for low-level access to resources
Chapter 6,Resources
ServletConfigAware
Current ServletConfig
the container runs in. Valid only in a web-aware SpringApplicationContext
Chapter 17,Web MVC framework
ServletContextAware
Current ServletContext
the container runs in. Valid only in a web-aware SpringApplicationContext
Chapter 17,Web MVC framework
- Spring Resources接口
- spring的resources---针对于资源文件的统一接口
- Spring Framework 5.0:Resources资源文件获取接口
- Spring参考手册 mvc:resources
- Spring -- 5.Resources
- Spring参考手册 mvc:resources 分类:
- Spring mvc <mvc:resources ***/> 作用
- Spring入门(Resources/ResourceLoader)
- Spring : 使用<mvc:resources 访问静态资源
- spring中bean的Resources(7)
- 关于spring <mvc:resources> 标签的使用
- java spring代码通用结构-resources
- Spring 框架概述(三)之Resources
- spring mvc:resources 静态资源访问
- spring bean装配(bean的作用域、bean的生命周期、Aware接口、Bean的自动装配Autowiring、资源文件Resources )
- Resources
- Resources
- Resources
- 【OpenCV】 split和merge操作
- [LeetCode] 021. Merge Two Sorted Lists (Easy) (C++/Python)
- HttpClient模块的HttpGet和HttpPost及Connection to refuse解决
- 用python脚本替换某文件夹下配置文件的$HOME
- C++ 类的析构函数学习笔记7
- Spring Resources接口
- 使用svn与eclipse管理本地代码
- Adding iAd in your App from Unity3d
- Android 开发 shareSDK 分享的时候 如何设置 登录和分享走客户端?
- SGU101 Domino
- HDU 1070 Milk
- Mysql与Oracle的区别
- 【OpenCV】颜色空间RGB与HSV(HSL)的转换
- Android学习总结六:ArrayList动态数组、Foreach syntax