[英]Bean validation error message not displaying
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.我试图将 bean 验证添加到我的表单中,当我将该字段留空时,右侧应该会出现一条红色消息,显示错误,但没有出现任何消息。 I'm using spring and JPA aswell
我也在使用 spring 和 JPA
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 JPA 中的代码是
@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;
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.