I have a
JEE 6 project.
Per the Spring in Action, Third Edition, I inserted a @Size(min=2, max=6, message="First Name must be between 2 and 20 characters") in front of a private field like this in my domain class:
@NotEmpty
@Size(min = 2, max = 20, message="First Name must be between 2 and 20 characters")
private
String firstName;
----
Then, in the
JSP, I inserted the form:errors tag, like this:
<form:input type="text" path="firstName" id="firstName" class="textfield" />
<form:errors path="firstName" cssClass="error"/>
----
In the CSS I added the "cssClass" tag like this:
span.error {
color: red;
font-size: 8pt;
}
In the Controller class, I have a @Valid in the method that the JSP POSTs to.
----------------
Yet, when I run the class and intentionally leave the firstName field blank, I just go to the regular display page with no error displayed.
Clearly, I'm missing something.
What is still required to get the form validation to display the "message" next to the field that has violated the @Size validation?
Thanks
-m