In an HTTP request, if it is a GET request, the form parameter is appended to the URL in name=value&name1=value1 form and, if it is a POST request, the form parameter is in the request body and is also name=value&name1= The Value1 form is in the request body. From the Chrome developer tools you can see the following (here is the readable form, not the actual request format of the HTTP request protocol):
GET Request:
[Plain] View Plain copy Requesturl:http://127.0.0.1:8080/test/test.do?name=mikan&address=street request method:get status code:200 ok request headers accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q= 0.8 accept-encoding:gzip,deflate,sdch accept-language:zh-cn,zh;q=0.8,en;q=0.6 alexatoolbar-alx_ns_ph:alexatoolbar/alxg-3.2 connection:keep-alive Cookies: jsessionid=74ac93f9f572980b6fc10474cd8edd8d host:127.0.0.1:8080 Referer:http:// 127.0.0.1:8080/test/index.jsp user-agent:mozilla/5.0 (windows nt 6.1) AppleWebKit/ 537.36 (Khtml, like gecko) Chrome/33.0.1750.149 Safari/537.36 query string parameters name:mikan address:street response headers content-length:2 DATE:SUN, 11 MAY 2014 10:42:38 GMT server:apache-coyote/1.1
POST request:
[Plain] View Plain copy requesturl:http://127.0.0.1:8080/test/test.do Request method: post status code:200 ok request headers accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding: gzip,deflate,sdch accept-language:zh-cn,zh;q=0.8,en;q=0.6 AlexaToolbar-ALX_NS_PH: alexatoolbar/alxg-3.2 cache-control:max-age=0 connection:keep-alive content-length:25 content-type:application/x-www-form-urlencoded Cookie:JSESSIONID= 74ac93f9f572980b6fc10474cd8edd8d host:127.0.0.1:8080 Origin:http://127.0.0.1:8080 referer:http://127.0.0.1:8080/test/index.jsp user-agent:mozilla/5.0 (Windows NT 6.1) applewebkit/537.36 (Khtml, like gecko) chrome/33.0.1750.149 safari/537.36 form data name:mikan address:street Response Headers content-length:2 date:sun, 11 may 2014 11:05:33 gmt server:apache-coyote/1.1
Notice here that the content-type of the POST request is application/x-www-form-urlencoded, and the parameter is in the request body, the form Data in the request above.
In the servlet, you can get form parameters in the form of Request.getparameter (name).
And if you use native Ajax Post requests:
[JavaScript] view plain copy function getxmlhttprequest () {var xhr; if (window. ActiveXObject) {xhr= new ActiveXObject ("Microsoft.XMLHTTP"); }else if (window. XMLHttpRequest) {