私はSpring MVCとVelocityを使用しているアプリケーションを持っています。私の書式の1つでは、書式に関連するすべてのエラーをページ上部に表示したいと考えています。私は#springShowErrorsマクロを使用して特定のフィールドに関連するエラーを表示する方法を理解しましたが、個々のアイテムの隣にエラーを表示するのではなく、フォームの上部に大きなエラーブロックを1つ置きたい。VelocityテンプレートのすべてのSpringフォームエラーを表示
私はグーグルのビットをかなりやったし、少数の人々は
#if ($status && $status.errors.hasErrors())
#foreach($error in $status.errorMessages)
<p>$error</p>
#end
#end
のようなものを示唆している...しかし、ちょうど私を付ける初期#springBindマクロの下に置かれたとき、これは私に何も出力を与えませんコマンドオブジェクトをフォームに追加します。各フィールドの#springFormInputマクロの直後に#springShowErrorsを置くと正常に動作するので、バリデータが実行中でエラーが発生しています。
アイデア?私は本当にばかげた何かを見逃しましたか?
はここだけ最初#springBind後に私の非稼働の試みで、任意のヘルプやアドバイスを
<form name="standardForm" id="standardForm" method="post" action="#springUrl("/requestAccess")">
#springBind("accessRequest")
#if ($status && $status.errors.hasErrors())
#foreach($error in $status.errorMessages)
<p>$error</p>
#end
#end
<fieldset>
<label for="name">Name</label>
#springFormInput("accessRequest.name" " ")
<label for="company">Company</label>
#springFormInput("accessRequest.company" " ")
<label for="title">Title</label>
#springFormInput("accessRequest.title" " ")
<label for="email">Email</label>
#springFormInput("accessRequest.email" " ")
<button type="submit" value="send">Send</button>
</fieldset>
</form>
おかげで完全な形です!
これは完全に機能しました!あなたの助けをありがとう! – KMitchell
甘い!おかげでロブ:)... –