Skip to content

Struts2 i18n messages

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> 

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?


Just use <message key="key_name"/> inside your ActionClass-validation.xml

Then you define key_name in

Make sure you have request_locale in your stack.