get请求和post请求的区别

2012/03/17 1853点热度 0人点赞 0条评论

 * 请求的时机:

      * 什么情况下是get请求.

          * 直接在地址栏输入信息

               http://localhost/yxkong/b.html?a=9

          * 网页中a标签使用的也是get请求

                <a href="b.html">b,html</a>    

          * 表单的请求方法是get也是get请求.

<form action="b.html" method="get">
       <input type="submit" name="ok" value="保存">
</form>

      * 什么情况下是post请求.

           表单的请求方法是post是post请求

<form action="b.html" method="post">
      <input type="submit" name="ok" value="保存">
</form>

   * 传递的数据

       * GET方式的特点:在URL地址后附带的参数是有限制的,其数据容量通常不能超过1K/1024B。

       * post请求传递的数据量大.

       

  * 特殊情况:

      * 表单如下

<form name="form1" action="./formGetPost?username=999" method="get">
         用户名:<input type="text" name="username" value="123"><br>
         密码:<input type="password" name="psw"><br>
        <input type="submit" value="保存"><br>
</form>

    * 如果method="get",表单中的组件的值是附着在./formGetPost的后面传递到服务器端的

       * 如果./formGetPost?username=999"后面的参数名称和表单组件的相同,则表单组件的参数名称覆盖路径后面的参数的名称

   

    * 如果method="post",表单中的组件的值不是附着在./formGetPost的后面传递到服务器端的。

       * 所以都可以传递过去,服务器端获取的是两个值

       

    * 请求路径后面的参数的格式:

            *  请求的路径?参数1=参数值1&参数2=参数值2&参数3=参数值3

            *  例如:./formGetPost?username=999&psw=123456&sex=male&.....

yxkong

这个人很懒,什么都没留下

文章评论