任意の要素の css クラスをモデルのバインド状態にバインドする方法はありますか?
<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>
このコードでは、エラーがない場合とエラーがある場合にlogin-error
のクラスを管理する必要があります ( second についても同じ考えです)。control-group
control-group error
control-group
ここでの一般的な解決策は何ですか?
アップデート
バインドエラーがない場合に必要なものは次のとおりです。
<div class="control-group"> <!-- !!!!!!!!!!!! -->
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
バインドエラーが発生したときに必要なものは次のとおりです。
<div class="control-group error"> <!-- !!!!!!!!!!!! -->
<label>Login</label>
<form:input path="name" />
<span class="help-inline"><form:errors path="name" /></span>
</div>
解決策を探しています。