Bean validation error message not displaying

Viewed 82

im trying to add bean validation to my form, when I leave the field blank,a red message should appear to the right displaying the error but no message appears. I'm using spring and JPA aswell

the code in the form is

        <tr>
            <td><form:label path="name">Name</form:label></td>
            <td><form:input path="name" /></td>
            <td style="color:red"><form:errors path="name"/> </td>
        </tr>

the code in the JPA is

@Basic(optional = false)
@NotNull
@Column(name = "name")
@NotBlank(message = " field cannot be empty")
@Size(max = 50, message = "must be equal to or less then 50 chars")
private String name;
1 Answers

After experimenting, I figure out the problem. I had just max, the message will only display if you have max and min or just min.

max and mix

 @Size(min = 1, max = 50, message ="must be 50 characters or less")

min

@Size(min = 1,  message ="must be 50 characters or less")
Related