动态Spring消息源

时间:2011-03-10 18:03:33

标签: spring messages

我即将扩展org.springframework.context.support.AbstractMessageSource,它允许我在Spring中动态添加和编辑消息。我计划将这些值存储在数据库中。有什么东西可以做到这一点吗?我应该想到一种不同的方法吗?

以下是要求:

  • 我必须能够添加消息
  • 我必须能够编辑消息
  • 这些添加和修改应立即进行

1 个答案:

答案 0 :(得分:0)

不确定

开发自定义MessageSource并将其设置为现有的父级(例如,基于属性文件)。

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>message/messages</value>
        </list>
    </property>

    <property name="parentMessageSource">
        <bean class=com.example.DatabaseMessageSource"/>
    </property>
</bean>