为什么我在html中输入的日期会为空?

mspsb9vt  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(136)

我试图让用户输入一个日期作为生日,然后将其存储到数据库(mysql)。输入行如下所示:

<p style="position:relative; left:30px; top:30px;">Date of Birth:
        <input type="Date" max="2020-12-31" th:field="*{birth}" required></p>

用户类具有属性:

@Column(name="birth", nullable=false)
    @DateTimeFormat(pattern = "yyyy-mm-dd")
    private Date birth;

默认的getter和setter。
在mysql中,出生类型设置为date。
但是我得到了一个错误:notnull属性引用了一个null或临时值:com.cms.prototype.user.request.birth;嵌套异常为org.hibernate.propertyvalueexception:not null属性引用null或临时值:com.cms.prototype.user.request.birth
其他用户输入可以正确地存储在数据库中。如果将nullable设置为true,则列中的值为null。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题