doGet和doPost的区别

本文详细对比了HTTP请求方法GET与POST的区别。GET方法适合用于从服务器检索信息,并体现在URL中,而POST则适用于向服务器发送数据,没有长度限制且更安全。文章还探讨了两种方法在实际应用中的具体场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

get和post的区别并非在地址栏中看到的那么简单,二者的不同来自于协议本身。向服务器发送请求的形式不同

 

GET/zl/login.jsp?username=vonzhou&password=vonzhou HTTP/1.1(CRLF)

Host:127.0.0.1

......

Connection: keep-alive

 

 

POST /zl/login.jsp HTTP/1.1(CRLF)

Host:127.0.0.1

......

Connection: keep-alive(CRLF)

(CRLF)

username=vonzhou&password=vonzhou

 

另外,

doGet is used when there is are requirement of sending dataappended to a query string in the URL. The doGet models the GET methodof Http and it is used to retrieve the info on the client from some server as arequest to it.The doGet cannot be used to send too much info appended as a querystream. GET puts the form values into the URL string. GET is limited toabout 256 characters (usually a browser limitation) and creates reallyugly URLs.

POST allows you to have extremely dense forms and pass that to theserver without clutter or limitation in size. e.g. you obviously can'tsend a file from the client to the server via GET.  POST has no limit on the amount of data you can send and because the data does not show up on the URL you can send passwords. But this does not mean that POST is truly secure. For real security you have to lookintoencryption which is an entirely different topic

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值