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