I am using Struts 2 and I created a simple application following a tutorial I found.
I’ve created a <MyActionClass>-validation.xml
file and I wonder how can I display the validation messages based on multiple languages?
<field name="password"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>You have to enter a password.</message> </field-validator> </field>
Can I get the messages from a localized .properties
file or do I have to use some other kind of validation?
Should there be validation XML files for every locale?
Advertisement
Answer
Just use <message key="key_name"/>
inside your ActionClass-validation.xml
Then you define key_name
in
global.properties global_vn.properties
Make sure you have request_locale
in your stack.