【问题标题】:How can I define a custom message source for a spring web flow?如何为 Spring Web 流定义自定义消息源?
【发布时间】:2011-12-24 08:16:13
【问题描述】:

spring webflow 文档提到他们将消息添加到流的方式是在流内的文件 messages.properties 中定义有关该流的所有消息:

国际化消息在 Spring MessageSource 访问的消息包中定义。要创建特定于流的消息包,只需在流目录中定义 messages.properties 文件。为您需要支持的每个其他语言环境创建一个默认的 messages.properties 文件和一个 .properties 文件。

在我们的 web 应用程序中,我们混合使用 Spring Webflow 和专有框架。我们将所有的国际化消息都放在一个文件中,我们希望 Spring Webflow 可以访问这个文件,而不是在项目中乱扔几十个属性文件。有没有办法为 spring webflow 配置消息源,还是我们坚持使用 messages.properties?

【问题讨论】:

    标签: spring internationalization spring-webflow


    【解决方案1】:

    在您的应用程序上下文 XML 文件中添加这样的内容:

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename"><value>classpath:yourSharedResourceBundle</value></property>
    </bean>
    

    只要文件位于类路径中,就应该使用它。

    【讨论】:

    • 这意味着,webflow 神奇地抓取了一个“messageSource”bean。我的工作做得很好,非常感谢。
    • @JanThomä messageSource 是约定,是的。很高兴它有帮助。
    猜你喜欢
    • 2016-09-18
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2015-07-29
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多