【问题标题】:PropertyPlaceholderConfigurer vs ReloadableResourceBundleMessageSourcePropertyPlaceholderConfigurer vs ReloadableResourceBundleMessageSource
【发布时间】:2013-12-24 11:00:11
【问题描述】:

在 Google 上搜索如何在 Spring 3 中配置属性文件,我得到了许多不同的答案。我发现ReloadableResourceBundleMessageSourcePropertyPlaceholderConfigurer 可用于从属性文件中获取属性。有人可以解释一下这些之间的区别吗?

【问题讨论】:

    标签: spring-3 properties-file


    【解决方案1】:

    PropertyPlaceholderConfigurer

    当我们需要加载一些属性文件,其属性在spring的applicationcontext.xml中使用时,我们使用PropertyPlaceholderConfigurer。我们可以直接使用 JSTL 表达式来使用属性。

    ReloadableResourceBundleMessageSource

    当我们需要使用applicationcontext.xml之外的属性文件时,我们使用ReloadableResourceBundleMessageSource。在 applicationcontext.xml 中无法访问使用 ReloadableResourceBundleMessageSource 加载的属性

    【讨论】:

      【解决方案2】:

      PropertyPlaceholderConfigurer 用于在应用程序上下文中或带有 @value 的代码中使用的属性文件。

      ResourceBundleMessageSource 用于您希望在 jsp 中直接显示给用户的消息的国际化和本地化 (i18n),或者通过在组件内连接消息资源 bean 从代码中显示。

      【讨论】:

        猜你喜欢
        • 2013-12-08
        • 1970-01-01
        • 2017-02-02
        • 2015-06-25
        • 2012-10-08
        • 2012-04-27
        • 1970-01-01
        • 2014-05-04
        • 1970-01-01
        相关资源
        最近更新 更多