Spring MVC "The request sent by the client was syntactically incorrect ()" solution.

Source: Internet
Author: User

When validating @datetimeformat annotations with the SpringMVC3 framework, a singular error is encountered, as long as the Date field in the form is entered with a value of the following error:


It's confusing. Looked for a long time, also tried a lot of online methods, such as some said the lack of Joda-time-2.3.jar package (later confirmed that this is not the reason).

The following snippet of Java code is as follows:

@Resourcepublic class Employee {private string id;private string lastname;private int gende;private string email; @DateTim Eformat (pattern= "YYYY-MM-DD") Private Date birth;private Department Department;

The page reads as follows:

<form:form action= "${pagecontext.request.contextpath}/emp" method= "POST" modelattribute= "Employee" ><c:if Test= "${empty employee.id}" >lastname:<form:input path= "LastName" value= ""/></c:if><c:if test= "${ !empty employee.id} "><form:input type=" hidden "path=" id "></form:input><input type=" hidden "name=" _method "value=" PUT "></input></c:if><br><%HashMap<String,String> gendes = new HashMap <String,String> (); Gendes.put ("0", "female"), Gendes.put ("1", "male"), Request.setattribute ("Gendes", gendes); %>gender:<br><form:radiobuttons path= "Gende" items= "${gendes}" delimiter= "<br>"/><br> Email:<form:input path= "Email"/><br>department:<form:select path= "Department.depid" items= "${" Departments} "itemlabel=" Depname "itemvalue=" depid "></form:select><br>birth:<form:input path=" Birth "/><br><input type=" Submit "value=" Submit "></input></form:form> 

This configuration is included in the Springmvc.xml configuration:

<mvc:annotation-driven></mvc:annotation-driven>

From the above, it is really impossible to find out what the problem, and later to write a simpler test found that the original Java code in the Date type eclipse by default refers to the Java.sql.Date class, rather than the java.util.Date we want to introduce. It will be ready immediately after the correction.

Find this problem on the internet and found a lot of friends also encountered, it may also be this problem, I hope to help everyone.




Spring MVC "The request sent by the client was syntactically incorrect ()" solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.