Springmvc Form form submission 400 error

Source: Internet
Author: User
Tags html form apache tomcat

Error code:

HTTP Status 400-

type Status Report

Message

Description The request sent by the client was syntactically incorrect.

Apache tomcat/7.0.47

Reason:


The server was unable to understand the request because of a malformed syntax. Without modification, the client program cannot repeat the request.
An error occurred while processing the JSON data from the foreground AJAX request to the corresponding entity class in the Action in SPRINGMVC:
The bad request, the background is not an error, 400 refers to the requests are invalid (the request has a syntax problem or can not meet the request).

Workaround:

Checks whether the type inside the JavaBean of the entity class is consistent with the Springmvc form's form table sole name.
My error is due to the fact that two associated entity classes cause the name names in the form form to be inconsistent:
Employee.java
 Private Integer ID;  Private String lastName;  Private String email;  Private int gender;  Private Department Department;  // Non-parametric construction method to omit // a method of constructing a parameter to omit // Setter and Getter methods to omit

Department.java

Private Integer ID; Private String departmentname;         // Non-parametric construction method to         omit // a method of constructing a parameter         to omit // Setter and Getter methods to omit

Form form:

<!--The model property of the binding can be specified through the Modelattribute property, and if the property is not specified, the command's form Bean is read from the request domain object by default, and if the property value does not exist, the Birth Error -    <Form:formAction= "Emp-save"Method= "POST"Modelattribute= "Employee">        <!--the Path property corresponds to the Name property of the HTML form label -LastName:<Form:inputPath= "LastName"/> <BR>Email:<Form:inputPath= "Email"/> <BR>Gender:<form:radiobuttonsPath= "Gender"Items= "${genders}"/> <BR>Department:<Form:selectPath= "department"Items= "${dapartments}"Itemlabel= "Departmentname"Itemvalue= "id"></Form:select><BR>        <inputtype= "Submit"value= "Submit">    </Form:form>

Change path= "department" to Path= "Department.id "

By this point, my problem has been solved. You are welcome to correct me

Springmvc Form form submission 400 error

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.