JQuery Ajax Request Submission Background getparameter receive no data

Source: Internet
Author: User

A summary of the problems encountered today

jquery's $ajax ({

  contentType: "Application/json",//content encoding type when sending information to the server.

})

When such a method is submitted, if the specified contenttype is Application/json, then the background through the traditional getparameter ("attribute name") can not get the data passed by the front end,

At this point you need to use

http://blog.csdn.net/mhmyqn/article/details/25561535 the method here to get it back; The code is as follows:

privatestring getrequestpayload (httpservletrequest req) {STRINGBUILDERSB=NewStringBuilder (); Try(Bufferedreaderreader =Req.getreader ();) {                            Char[]buff =New Char[1024];                            Intlen;  while(len = reader.read (buff))! =-1) {sb.append (buff,0, Len); }                   }Catch(IOException e) {e.printstacktrace ();         } returnsb.tostring (); }

I'm using the jquery version is 1.10, is not required to specify Content-type, it will be used by default: content-type:application/x-www-form-urlencoded

My problem is to set up the Content-type, and take the getparameter way to take the value, so it will not be taken;

JQuery Ajax Request Submission Background getparameter receive no data

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.