¿Cómo puedo definir una fuente de mensaje personalizada para un flujo web de primavera?

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:

Internationalized messages are defined in message bundles accessed by a Spring MessageSource. To create a flow-specific message bundle, simply define messages.properties file(s) in your flow's directory. Create a default messages.properties file and a .properties file for each additional Locale you need to support.

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?

preguntado el 08 de noviembre de 11 a las 10:11

1 Respuestas

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>

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

respondido 14 nov., 11:22

That means, that the webflow magically grabs a "messageSource" bean. Well worked on my end, thank you very much. - Jan Thomä

@JanThomä messageSource is the convention, yes. Glad it helped. - Scott A

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.