JavaWeb学习笔记:POST和GET
来源:互联网 发布:php 类的魔术方法 编辑:程序博客网 时间:2024/06/12 00:08
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 FoundResponse 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.1Request 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.36Query String Parameters user:zhao password:123456
POST方式的Headers
General Remote Address:127.0.0.1:8989 Request URL:http://localhost:8989/test/loginServlet Request Method:POST Status Code:404 Not FoundResponse 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.1Request 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.36Form Data user:zhao password:123456
0 0
- JavaWeb学习笔记:POST和GET
- JavaWeb学习笔记—Get和Post请求
- JavaWeb学习之Get请求和POST
- JavaWeb学习笔记(三)--- post和get的区别、session和cookie的区别、forward和redirect的区别
- 学习笔记 post和get的区别
- JavaWeb---get请求和Post请求
- 【JAVAWEB】--HTTP协议GET和POST请求
- 【学习笔记】jQuery中$.get()和$.post()的用法
- ASP.Net学习笔记006--Get和Post的区别
- javaweb的request的get和post方法
- 自用的Javaweb中Get和Post请求方法
- AJAX 学习笔记(4) GET与POST
- IOS HTTP GET POST学习笔记
- 学习笔记之--post/get/put
- ajax学习笔记之get&post
- JSP和servlet学习笔记一HTttp、get和post、 URL编码
- AJAX学习笔记之 客户端请求方式 get 和post 模式
- nodejs学习笔记(五)——处理get和post请求
- Paxos理解之我见(二)
- 常用的Git命令
- hdu 1018题 Big Number
- 创建多个Git帐号
- Linux的CFS(完全公平调度)算法
- JavaWeb学习笔记:POST和GET
- 【Android-NDK】错误 undefined reference to '__atomic_fetch_add_4'
- IOS resizableImageWithCapInsets 拉伸图片时出现变形不成功
- 在查询里结合表,使用子查询定义未确定数据
- 黑马程序员—c语言基础—Printf函数的介绍以及注意事项
- Altium Designer PCB 常用功能键
- webstorm快捷键
- HDU 3440--House Man【差分约束,建图难】
- hdu 4349 Xiao Ming's Hope