The 415 (Unsupported media type) error is always returned when data is passed from the page to the background via Ajax, and the data is not available in the background. As shown in the following:
In trying to solve this problem, we first have to understand the concept:
- @requestmapping @ requestbody and @responsebody usage, this has a lot of blogs to refer to.
- The difference between a JSON object and a JSON string.
Person ={"name": "Nadech"}//This is a JSON object
person= "{" name ":" Nadec "}"//This is a JSON string
Both can be converted by json.parse () and json.stringify ().
@requestbody the process of transmitting JSON data (JSON strings) back to the platform by Ajax
, first we want to guarantee the transmission of the Content-type:application/json charst= "Utf-8
The second arrow in the transmitted JSON string indicates the form, not a pile of letters.
By specifying Content-type in Ajax and Json.stringify () to data, you can then check the header to see if it is correct.
Second, there is no above error, consider the version compatibility issue of Jackson and spring MVC and the configuration of SPRINGMVC.
Which, in terms of configuration, such as
Note that the code of the red arrow indicates that the code is usually directly behind the scan controller package. The meaning of a literal understanding is the annotation drive of MVC.
Summarize:
You need to consider the JSON format for the transfer and Jackson's version and configuration issues.
Transfer JSON data through Ajax and spring background