I am trying to run a project in Spring MVC. Here is the code
index.jsp
<%@page contentType=\"text/html\" pageEncoding=\"UTF-8\"%>
<%@taglib
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
.
Add this:
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(true);
binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
}
To your controller.