04 HTTP协议中的get/post方法
来源:互联网 发布:淘宝嘉年华有假货吗 编辑:程序博客网 时间:2024/06/04 18:00
1、概述
我们知道访问网页的方式是先向服务器发送一个请求request,然后服务器经过请求的处理,向请求者返回一个响应response。如果请求正确,则会返回相应的网址,如果请求错误,则提示404错误信息。下面将通过一个小示例来说明与服务器对话请求中get与pos方法。
2、get方法
1)部分示例代码
<form class="ui form" action="https://duckduckgo.com" method="get"> <div class="field"> <label>Content</label> <input type="text" name="q" value=""> </div> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="ia" value="images"> <label>Search for images</label> </div> </div> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="ia" value="web"> <label>Search for web</label> </div> </div> <button class="ui green button" type="submit"> Submit </button> </form>解析:
a、通过一个表单的格式来使用get方法,在表单第一行声明method="get";
b、使用一个文本框和两个单选框来来进行搜索,其中文本框中的属性name=“q” value=""为网页搜索内容,name="ia" value="web"为选择内容,对应网站中:
c、使用button来提交表单。
2)网页效果
3)get请求的效果
说明:网址中显示出请求的信息:?q=cat&ia=web。get方法通常用来对网页的翻页和查询。
3、post方法
1)部分示例代码
<form class="ui form" action="https://duckduckgo.com" method="post"> <div class="field"> <label>Content</label> <input type="text" name="q" value=""> </div> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="ia" value="images"> <label>Search for images</label> </div> </div> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="ia" value="web"> <label>Search for web</label> </div> </div> <button class="ui blue button" type="submit"> Submit </button> </form>解析:
a、与get方法相比,post在表单中方法改为method="post"。
2)网页效果
3)post请求效果
说明:网址中不会出现请求的属性信息,而是在网页的请求主体中,这样可以防止信息在网址上直接显示。因此post常常用于提交数据(登入界面或控制面板)
阅读全文
0 0
- 04 HTTP协议中的get/post方法
- HTTP协议中的GET和POST方法
- http协议中的get与post方法区别分析
- HTTP协议中的GET、POST请求
- HTTP协议中的POST、GET详解
- http协议中的get和post
- iOS HTTP协议的get,post方法
- http协议简介与GET、POST方法
- HTTP协议POST、GET方法实现
- http 中的post和get方法
- HTTP协议中,GET方法与POST方法比较
- Http方法 GET/POST
- http:get&post方法
- HTTP 协议中的GET 和POST 的区别
- iOS中的HTTP协议 如何使用GET和POST
- http协议中的post和get有何区别?
- Http协议GET与POST
- HTTP协议,GET/POST学习心得
- JSON与XML的区别比较
- 安卓苹果IOS微信共享实时位置修改方法,微信共享实时位置如何作假
- JS 实现完美include
- 3-3 构造函数的调用(高级)
- 一个简单的自适应调整字体大小view
- 04 HTTP协议中的get/post方法
- 散列3 QQ帐户的申请与登陆
- codeforces 888D Almost Identity Permutations (组合数+错排)
- 秒杀系统设计
- Eclipse装AmaterasUML插件
- HDU2036
- windows主机与虚拟机Linux共享文件夹
- ReactNative安卓端的打包发布
- leetcode729. My Calendar I