get请求和post请求的区别主要有两点
2018-01-03 本文已影响79人
孤_岛
get请求和post请求的区别主要有两点
-
get
请求可以被缓存而post
请求不能被缓存 -
get
请求的传参方式和post
请求的传参方式不同get
请求传参: 通过url后面带参数http://www.test.com/path/to/resource?id=faef123&name=foo&age=122
post
请求传参:在请求实体中由于
get
和post
传参方式的不同,所以决定了他们会有以下区别:-
由于浏览器对
url
的长度限制(一般为2083字符)限制,get
请求的长度是有限的,而post
请求则没有大小限制 -
由于get请求的参数会暴露在
url
中,所以安全性会更低一些 -
get
请求只能使用application/x-www-form-urlencoded
编码,而post
请求可以使用多种编码格式application/x-www-form-urlencoded
/multipart/form-data
/application/json
-
get
请求可以保存在浏览器历史中,而post
请求不会
-