本文介绍了如何为Spring Web流定义自定义消息源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The spring webflow documentation mentions that their way of adding messages to a flow is to define all messages regarding that flow in a file messages.properties inside the flow:

在我们的Web应用程序中,我们结合使用了Spring Webflow和专有框架.我们将所有国际化的消息保存在一个文件中,我们希望Spring Webflow可以访问此消息,而不是用数十个属性文件来填充我们的项目.有没有一种方法可以为Spring Webflow配置消息源,还是我们只能停留在messages.properties上?

In our webapp we use a mix of Spring Webflow and proprietary frameworks. We have all our internationalized messages in a single file and we'd like to have Spring Webflow access this one instead of littering our project with dozens of properties files. Is there a way to configure the message source for a spring webflow or are we stuck to messages.properties?

推荐答案

在您的应用程序上下文XML文件中放置以下内容:

Put something like this in your application context XML file:

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

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

As long as the file is located on the classpath it should be used.

这篇关于如何为Spring Web流定义自定义消息源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:53
查看更多