Spring MVC Error Tag Example

In this article we will explain the Spring MVC error tag and its usage. A Spring MVC error tag is normally used for showing any validation error during validating/submitting the data on the forms.

Spring MVC Error Tag

A error tag in spring is defined as follows

This tag is rendered as a SPAN html tag

The Error message that needs to be displayed in the Error Tag is set in the Controller or Validator class as shown below

If we want to display all the errors that are set in the validators then we can use the following path=”*” attribute

If we do not want to display the error message in the SPAN, then we can define the html tag in which we want the error to be displayed

This will show the error message in a DIV tag as follows

Also we can add external css classes to the error message as shown below

cssErrorClass would be translated in class attribute as shown below

Please do let see the other form tags that are used.