In a web project, jsp submits json data to the background and reports a 400 error.

When submitting data to the background through ajax on the jsp page, a 400 error was reported. After consulting the information, the cause and solution were found as follows:
HTTP error 400
400 Request error
Because the syntax format is incorrect, the server cannot understand this request. Without modification, the client program cannot repeat this request.

Reasons:
1. The field name or field type
of the data submitted by the front end is inconsistent with the entity class of the back end , which cannot be encapsulated; 2. The data submitted by the front end to the back end should be of json string type, and the front end does not convert the object into a string Types of;

Solution:
1) Compare the field names and types to ensure consistency;
2) Use stringify to convert the object passed by the front end into a string, data: JSON.stringify (param).

Note: Finally, it is found that the time in the data is an incorrect type. The time type is the Date type, and it should be in the java.sql.Date package, not in the java.util.Date.

Published 111 original articles · won praise 2 · Views 3533

Guess you like

Origin blog.csdn.net/m0_38088647/article/details/103414553