The request sent by the client was syntactically incorrect.-Spring MVC + JDBC Template

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="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.


I came across the same error this morning. The problem with my code was that I had declared a variable as an integer in my form binding object but on the actual form I was capturing text. Changing the variable to the correct type worked out for me


This happens when the defined binding does not match to what the user is sending. The most common issues are:

  • Missing PathVariable declaration
  • Incomplete PathVariable declaration (for example missing value="variableName")
  • Wrong data type, such as Sotirios Delimanolis answer above. If the Class of an input parameter cannot be serialized the request is not processable

So, in general, be sure that:

  • Each PathVariable is declared
  • A value is assigned that corresponds to value to be match in the path - @PathVariable(value="myVariableName", String myVariable) where the path defines @RequestMapping(value = "/userInfo/myVariableName", method = RequestMethod.GET)
  • Each class declared for a PathVariable must be serializable.