0

Struts 2 の使い方を学びたいので、見つけたチュートリアルに従って簡単なアプリケーションを作成しました。

ファイルを作成しましたが<MyActionClass>-validation.xml、検証メッセージを複数の言語に翻訳するにはどうすればよいでしょうか?

<field name="password">
    <field-validator type="requiredstring">
        <param name="trim">true</param>
        <message>You have to enter a password.</message> 
                 <!-- How can I localize this message? -->
    </field-validator>
</field>

ローカライズされた .properties ファイルからメッセージを取得できますか、それとも他の種類の検証を使用する必要がありますか?

4

1 に答える 1

1

OK, I found it out myself. You have to create a .properties file for the class, then you can change the code from:

<message>You have to enter a password.</message> 

to:

<message key="[message key from the properties file]" />
于 2008-12-10T19:24:48.213 に答える