传递时间类型到后台报错

添加如下注解spring

@JSONField(format="yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")

无效日志

报错日志:orm

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 2 errorsit

 

解决方法:在controller加入如下方法io

@InitBinder //表单时间绑定
public void init(WebDataBinder binder) {
binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
}form

相关文章
相关标签/搜索