jquery's Ajax default contenttype and data format

Source: Internet
Author: User
Tags json

$.ajax of jquery (Url,[settings])
1. The default contenttype value is: application/x-www-form-urlencoded; Charset=utf-8
This format is the form submission format, the data is key1=value1&key2=value2 format
2. Although the Data property value of Ajax is in the format: {key1:value1,key2:value2}, it will eventually be submitted to the background in key1=value1&key2=value2 format
3. If Ajax is to interact with SPRINGMVC, the key1=value1&key2=value2 format, the background SPRINGMVC only need to define the object or parameters on the line, will be automatically mapped.
4. If the SPRINGMVC parameter has @requestbody annotations (receive json** String * * Format data), Ajax must convert the Date property value to a JSON string, not a JSON object (JS object, which will automatically be converted to Key=value form). Also, the value of the modified contenttype is: Application/json; Charset=utf-8, this adds the properties of the @requestbody annotation to customize the mapping to the value

Related Article

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.