所以我有以下模型:
@Entity
@Table(name = "Project")
public class Project implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "PROJECT_ID", unique = true, nullable = false)
private int projectId;
private String name;
...
@ManyToOne
@JoinColumn(name = "MANAGER_ID")
@NotEmpty(message = "test")
private User manager;
....
}
出于某种原因" @ NotEmpty"注释时给出以下错误 输入为空白:
org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是javax.validation.UnexpectedTypeException:HV000030:找不到类型为:com.springmvc.model.User的验证器。
我通过以下方式将我的值传递给后端:
<form:select path="manager" class="selectpicker form-control">
<form:option value="" >Alle managers</form:option>
<c:forEach var="manager" items="${managers}">
<form:option value="${manager.userId}" >${manager.getUserDetail().firstName}
${manager.getUserDetail().lastName}</form:option>
</c:forEach>
</form:select>
我做错了什么?
答案 0 :(得分:2)
将@NotEmpty替换为@NotNull,这样可以解决您的问题。