1

以下のエラーを削除する方法はありますか?それは私のvalidation.xmlからのものです。それは私にとってすでに冗長です...ありがとう。

    Username must not be blanks
    Password must not be blanks

Username must not be blanks ---> How to remove this?
UserName:   
Password must not be blanks ---> How to remove this?
Password: 

実際に私がやりたいのは、フィールドの右側に表示されるエラーメッセージです。

UserName: ___________________  * Username must not be blanks
Password:____________________  * Password must not be blanks    
4

1 に答える 1

1

フォームにシンプルなテンプレートを使用します。

<s:form theme="simple" ...>

次に、<s:fielderror>タグを使用して、フィールドエラーを好きな場所に配置します。

<s:form ...>
    <s:textfield key="field1"> 
    <s:fielderror>
         <s:param>field1</s:param>
    </s:fielderror>
    ...
</s:form>

次に、CSSを操作するだけでそのレイアウトを実現できます。

編集:<s:fielderror>あなたがあなたのフィールドを置くならば、エラーはリストにあるようです。2つのオプションがあります。テンプレートfielderror.ftlを編集するか、次のようstruts2.jarに特定のエラーにアクセスします。<s:property>

<s:property value="fieldErrors.get('field1').get(0)" /> 

このコードは、フィールドの最初の検証エラーのみを抽出します。

于 2012-12-11T07:58:15.567 に答える