任意の要素のcssクラスをモデルのバインド状態にバインドする方法はありますか?コードのこの部分でSpring MVC - 検証エラーが発生した場合、親divのクラスを設定するには?
<form:form method="post" commandName="authForm" action="authenticate">
<div id="login-error" class="control-group">
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
<div class="control-group">
<label>Password</label>
<form:input path="password" />
<span class="help-inline"><form:errors path="password" /></span>
</div>
<input type="submit" />
</form:form>
Iは、(第2 control-group
について同じ考え方)があるエラーとcontrol-group error
がない場合control-group
にlogin-error
のクラスを管理する必要があります。
ここでよくある解決策は何ですか?
<div class="control-group error"> <!-- !!!!!!!!!!!! -->
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
解決策を探して:
<div class="control-group"> <!-- !!!!!!!!!!!! -->
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
は、ここで私はバインドエラーが発生した場合に必要なものです:
更新
は、ここで私は何のバインドエラーがないとき、必要なものです。
あなたの質問をさらに詳しくお聞かせください。私はあなたの問題を理解することができません。 –
@Japan Trivedi: – agibalov
更新済みhttp://stackoverflow.com/questions/1653438/spring-forms-how-to-check-for-error-on-specific-path –