java web入门--003【post 请求与 get 请求的区别】

post 请求与 get 请求的区别:
get请求 一般会把参数附着在请求的后面,并用?隔开。这样的话参数容易暴露,类似密码这样的参数等。
例如:
Request URL:http://localhost:8080/JavaWeb_001/actionServlet?user=user&password=user&submit=submit
特点:传送的数据是有限制的,一般限制在1kb以下;
post请求:
传送的参数被放在请求体里面
特点:传送的数据要比get方式传送的数据大得多。
总结:
get请求
(1)在浏览器中输入某个url或者点击某个超链接时,浏览器发送出的http请求均为get请求;
(2)如果在html表达form中将method设置成为了get,那么请求一定为get请求;
(3)使用get请求给web服务器传递参数的格式一般为以下格式:
Request URL:http://localhost:8080/JavaWeb_001/actionServlet?user=user&password=user&submit=submit
(4)使用get请求传输的数据一般都必须在1kb以下;


post请求:
(1)post请求主要是向web服务器提交表单form中的数据:form表单中的method设置为post
(2)post请求的方式传送的表单字段元素以及其数据作为http实体内容发送给web服务器,传送的数据量比get请求大得多;
如下所示:
Request URL:http://localhost:8080/JavaWeb_001/actionServlet
Request Method:POST
Status Code:404 Not Found
Remote Address:[::1]:8080
Referrer Policy:no-referrer-when-downgrade


Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:45
Content-Type:application/x-www-form-urlencoded
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/JavaWeb_001/login.html
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3004.3 Safari/537.36


user:user
password:user
submit:submit     ----请求中传递的数据参数

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值