get和post请求
1、get请求
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="#"method="get">
<input type="text"name="username"><br/>
<input type="password"name="password"><br/>
<input type="submit"value="提交"><br/>
</form>
</body>
</html>
2、post请求
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="#"method="post">
<input type="text"name="username"><br/>
<input type="password"name="password"><br/>
<input type="submit"value="提交"><br/>
</form>
</body>
</html>
3、get请求和post请求的区别
不同点:
(1)get请求的参数在URL中,post请求在请求体中。用户一般看不到请求体中的内容,post提交相对安全。
(2)请求缓存:GET 会被缓存,而post不会
post不管刷新页面多少次,都不会304状态。而get在未改变代码的情况下,第一次刷新为状态码为200,第二次刷新状态码变为304。
(3)get请求长度最多1024kb,post对请求数据没有限制(浏览器和服务器对其有一定的限制)。
相同点:GET和POST本质上都是TCP链接。但是由于HTTP的规定和浏览器/服务器的限制,导致他们在应用过程中表现出不同。
转载于//www.cnblogs.com/zhai1997/p/11275010.html
还没有评论,来说两句吧...