更新时间:2022-06-19 07:04:06
提交HTTP POST时必须绑定Date
. Spring不知道这是Date
,而是将其视为String
.
You must bind the Date
when you submit a HTTP POST. Spring does not know that this is a Date
, it sees it as a String
.
添加此内容:
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(true);
binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
}
致您的控制器.