国际化

1.在field-validator的message中含有{0}

例如

common.required = {0} is required.
common.family = Family
<field name="family.familyName">
        <field-validator type="requiredstring">
            <param name="trim">true</param>
            <message key="common.required">
                <argo key="common.family" />
            </message>
        </field-validator>
    </field>

以上写法,输出的message为{0} is required,不是预期的Family is required.

解决方法一

common.required = ${getText(fieldName)} is required.
family.familyName = Family
<field name="family.familyName">
    <field-validator type="requiredstring">
        <param name="trim">true</param>
        <message key="common.required"/>
    </field-validator>
</field>
解决方法二

<field name="family.familyName">
        <field-validator type="requiredstring">
            <param name="trim">true</param>
            <message>
                ${getText("requiredstring", {getText("common.family")})}
            </message>
        </field-validator>
    </field>

http://stackoverflow.com/questions/3297848/how-to-achieve-0-in-struts2-field-validation-message

你可能感兴趣的:(国际化)