Java 为什么我在html中输入的日期为空?
我试图让用户输入一个日期作为生日,然后将其存储到数据库(mysql)。 输入行的名称如下所示:Java 为什么我在html中输入的日期为空?,java,html,mysql,spring-boot,Java,Html,Mysql,Spring Boot,我试图让用户输入一个日期作为生日,然后将其存储到数据库(mysql)。 输入行的名称如下所示: <p style="position:relative; left:30px; top:30px;">Date of Birth: <input type="Date" max="2020-12-31" th:field="*{birth}" required></p&
<p style="position:relative; left:30px; top:30px;">Date of Birth:
<input type="Date" max="2020-12-31" th:field="*{birth}" required></p>
和默认的getter和setter
在mysql中,出生类型设置为日期
但我得到了一个错误:
NOTNULL属性引用空值或瞬时值:com.cms.PROTOTYPE.user.Request.birth;嵌套异常为org.hibernate.PropertyValueException:notnull属性引用空值或暂时值:com.cms.PROTOTYPE.user.Request.birth
其他用户输入可以正确地存储在数据库中。如果我将nullable设置为true,则在列中得到null
@Column(name="birth", nullable=false)
@DateTimeFormat(pattern = "yyyy-mm-dd")
private Date birth;