GET和POST
GET请求
- 在浏览器地址栏中输入某个URL地址或单击网页上的一个超链接时,浏览器发出的HTTP请求消息的请求方式为GET。
- 如果网页中的form表单元素的 method 属性被设置为了“GET”,浏览器提交这个FORM表单时生成的HTTP请求消息的请求方式也为GET。
- 使用GET方式传送的数据量一般限制在 1KB 以下。
- GET请求最大的一个特点就是把请求的参数附在URL的后面了,用问号连接。
POST请求
- POST 请求方式主要用于向 WEB 服务器端程序提交 FORM 表单中的数据: form 表单的 method 置为 POST
- OST 方式将各个表单字段元素及其数据作为 HTTP 消息的实体内容发送给 WEB 服务器,传送的数据量要比使用GET方式传送的数据量大得多。
程序测试
HTML代码
简单的提交账号密码代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <!-- method分别设置为get和post-->
    <form action="loginServlet" method="post">
        user:<input type="text" name="user"/>
        password:<input type="password" name="password"/>
        <input type="submit" value="Submit"/>
    </form>
</body>
</html>GET方式的Headers
可以看出,GET方式的Headers中Request URL:http://localhost:8989/test/loginServlet?user=zhao&password=123456账号和密码是附在URL后面的。
General
    Remote Address:127.0.0.1:8989
    Request URL:http://localhost:8989/test/loginServlet?user=zhao&password=123456
    Request Method:GET
    Status Code:404 Not Found
Response Headers
    Content-Language:en
    Content-Length:1032
    Content-Type:text/html;charset=utf-8
    Date:Sun, 26 Jul 2015 10:02:45 GMT
    Server:Apache-Coyote/1.1
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
    Connection:keep-alive
    Cookie:CKFinder_Path=files%3A%2F%3A1
    Host:localhost:8989
    Referer:http://localhost:8989/test/login.html
    User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36
Query String Parameters
    user:zhao
    password:123456POST方式的Headers
General 
    Remote Address:127.0.0.1:8989
    Request URL:http://localhost:8989/test/loginServlet
    Request Method:POST
    Status Code:404 Not Found
Response Headers
    Content-Language:en
    Content-Length:1032
    Content-Type:text/html;charset=utf-8
    Date:Sun, 26 Jul 2015 10:05:54 GMT
    Server:Apache-Coyote/1.1
Request Headers
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Accept-Encoding:gzip, deflate
    Accept-Language:zh-CN,zh;q=0.8
    Cache-Control:max-age=0
    Connection:keep-alive
    Content-Length:25
    Content-Type:application/x-www-form-urlencoded
    Cookie:CKFinder_Path=files%3A%2F%3A1
    Host:localhost:8989
    Origin:http://localhost:8989
    Referer:http://localhost:8989/test/login.html
    User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36
Form Data
    user:zhao
    password:123456 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号