Spring <form:errors> Tag

This tag displays a set of error messages prepared by a business logic component and stored as an errors object.


In your Validator, validate() method you can have some like this

errors.rejectValue("hobbies", "hobbies.required");

Properties File

The corresponding error messages are configured in the messages.properties file.

hobbies.required = Select at least one hobby


Now in JSP, you can display error messages like this

<form:checkboxes items="${hobbiesList}" path="hobbies" />
<form:errors path="hobbies" cssClass="error" />

path=”*” displays all error messages associated with any fields. For example :

<form:errors path="*"/>

You can also see how I have used Spring Errors Tag in our Spring Form Validation Example. For Reference, Click Here

, ,

No comments yet.

Leave a Reply