Struts2 i18n消息 [英] Struts2 i18n messages
问题描述
我正在使用Struts 2,并根据找到的教程创建了一个简单的应用程序.
I am using Struts 2 and I created a simple application following a tutorial I found.
我已经创建了一个<MyActionClass>-validation.xml
文件,我想知道如何显示基于多种语言的验证消息?
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>
我可以从本地化的.properties
文件中获取消息吗,还是必须使用其他某种形式的验证?
Can I get the messages from a localized .properties
file or do I have to use some other kind of validation?
每个地区都应该有验证XML文件吗?
Should there be validation XML files for every locale?
推荐答案
只需在ActionClass-validation.xml中使用<message key="key_name"/>
Just use <message key="key_name"/>
inside your ActionClass-validation.xml
然后您在
中定义key_name
global.properties
global_vn.properties
确保堆栈中有request_locale
.
这篇关于Struts2 i18n消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!