当前位置:H5W3 > 其他技术问题 > 正文

Post和Get 的问题解决


<form action=”test.do?p1=1″ method=”GET”>

<input type=”text” size=”10″ value=”2″ name=”p2″>

<input type=submit value=”Submit”>





    目前还不清楚是浏览器导致这种问题还是有规范约定这种处理方式。我的感觉是有规范进行这种约定,然后浏览器就把form的内容转换为一个URL,例如例子的情况,浏览器就把请求的   URL转换为test.do?p2=2了,忽略了action原先带的参数p1.而如果是POST方式,那么浏览器就不用做转换,直接提交了。




    看到一个讲解这个问题很详细的英文文章,有兴趣的自己看看:Methods GET and POST in HTML forms – what‘s the difference?


    When users revisit a page that resulted from a form submission, they might be presented with the page from their history stack (which they had probably intended), or they might be told that the page has now expired. Typical user response to the latter is to hit Reload.

    This is harmless if the request is idempotent, which the form author signals to the browser by specifying the GET method.

    Browsers typically will (indeed “should”) caution their users if they are about to resubmit a POST request, in the belief that this is going to cause a further “permanent change in the state of the universe”, e.g. ordering another Mercedes-Benz against their credit card or whatever. If users get so accustomed to this happening when they try to reload a harmless idempotent request, then sooner or later it‘s going to bite them when they casually [OK] the request and do, indeed, order a second pizza, or invalidate their previous competition entry by apparently trying to enter twice, or whatever.


本文地址:H5W3 » Post和Get 的问题解决

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址