您的位置:首页 > 编程语言 > Java开发

Spring 中加载资源文件

2008-10-17 16:01 218 查看
在Spring 中可以使用以下两个类加载资源文件:

org.springframework.context.support.ResourceBundleMessageSource


org.springframework.context.support.ReloadableResourceBundleMessageSource

后者可以不重起服务器的情况下,读取资源文件,所以可以随时更改资源文件。

以下为在其配置:

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">

<property name="basename">

<value>ApplicationResources</value>

</property>

</bean>

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">

<property name="basename">

<value>ApplicationResources</value>

</property>

</bean>

当上下文件配置文件被读取后,以在配置文件中指定的名字为基名的资源文件全部会被读入,并置于上下文中,这样以后就可以在上下文中读取,在页面上也可以使用Spring标签取得。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: