Detailed explanation of the difference between GET/ POST

1. Get is used to obtain data from the server, and Post is used to transfer data to the server.

2. Get adds the data in the form to the URL pointed to by the action in the form of variable=value, and the two are connected by "?", and each variable is connected by "&"; Post is to connect the data in the form The data is placed in the data body of the form, and is passed to the URL pointed to by the action according to the corresponding method of variables and values.

3. The data submitted by post is implicit, and all operations of Post are invisible to users; get is passed in the url (you can look at the address bar of your browser), which is used to pass some unnecessary confidential data. Get is insecure, because during transmission, the data is placed in the requested URL, and many existing servers, proxy servers, or user agents log the request URL to a log file, and then put it somewhere, In this way, some private information may be seen by third parties. In addition, the user can also directly see the submitted data on the browser, and some internal system messages will be displayed in front of the user together.

4. The amount of data transmitted by Get is small. When using Get, the size of the transmitted data is limited (note that the number of parameters is not limited), which is 2K; while Post can transmit a large amount of data, so only Post ( Of course there is another reason, which will be mentioned later).

5. Get restricts the value of the data set of the Form form to be ASCII characters; while Post supports the entire ISO10646 character set. The default is to use ISO-8859-1 encoding

6. Get is the default method of Form.

7. Another point to note is that the method used to obtain parameters through the get method is somewhat different from that through the post method:

 
 
post:request.getParameter("");
get: request.QueryString("");

<Note: When submitting by get, I also use request.getParameter() to get the passed parameters. Although request.setCharacterEncoding("utf-8") has been set, the Chinese parameters obtained are always garbled. But I didn't use the latter method to get the parameters. I changed it directly to post, and the Chinese display was normal. >


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326942683&siteId=291194637