I think the issue is that Spring doesn’t know how to deserialize the date your browser client sends when submitting the following input
field in
<tr name="tstest">
<td>Date Of Birth</td>
<td><form:input path="dateOfBirth" name="timestamp" value=""/>
<a href="https://stackoverflow.com/questions/20616319/javascript:show_calendar("document.tstest.timestamp', document.tstest.timestamp.value);"><img src="../images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a>
</td>
</tr>
Spring doesn’t know how to take the value that you enter into that field and convert it into a Date
object. You need to register a PropertyEditor
for that. For example, add the following to your @Controller
class
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(true);
binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
}
Obviously, change the SimpleDateFormat
to whatever your client is sending.
On a related note, you’re sending a 302 response by sending a redirect
return "redirect:/full-reg";
Remember that request and model attributes only live for the duration of one request. So when your client send the request to full-reg
, none of the form input parameters you sent originally exist any more. You should re-think how you do this.