【发布时间】:2015-02-03 03:43:29
【问题描述】:
我有一个带有 Joda DateTime 字段和以下验证规则的 User 模型类:
@NotEmpty
@DateTimeFormat(pattern="dd/MM/yyyy")
@Past
private DateTime dob;
提交注册表后,我收到此错误:
No validator could be found for type: org.joda.time.DateTime.
如何向该字段添加验证器?
【问题讨论】:
-
愚蠢的问题,但你有“import org.joda.time.format.DateTimeFormat;”在那个班级的某个地方?
-
我正在使用 org.springframework.format.annotation.DateTimeFormat
-
换我列出的那个
-
org.joda.time.format.DateTimeFormat 不是注释
-
是的,你是对的,我意识到我看错了。让我再试一次。你如何进行验证?你能展示你的方法和验证的代码吗?
标签: spring hibernate jodatime thymeleaf