表单操作 url 可以包含查询字符串值吗?
表单操作 url 可以包含查询字符串值吗?
can a forms action url contain querystring values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
表单操作 url 可以包含查询字符串值吗?
can a forms action url contain querystring values?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
是的,
可以。
但是
,当
method="get"
时,查询字符串将被删除并替换为表单输入名称/值(因为表单控件是构建GET
查询字符串的控件) 。将提交
param=bar
要保留该值,您应该在
form
上指定method="post"
。将提交
param=foo&otherparam=bar
将提交
param=foo¶m=bar
(因此,根据您处理请求的方式,您可以获得一个数组值或意想不到的结果)。Yes
it can.
But
when
method="get"
then the querystring will be stripped out and replaced by the form input names/values (since the form controls are those that build theGET
querystring).will submit
param=bar
To keep the value you should specify
method="post"
on theform
.will submit
param=foo&otherparam=bar
will submit
param=foo¶m=bar
(so, depending on how you process the request, you could get either an array value or unexpected results).是的,可以。
(按键)
Yes, it can.
(Keystrokes)
我刚刚使用简化的测试用例进行了检查:
action
为default.aspx?query=1
和一个提交按钮的表单。Page_Load
中的代码,用于写出Request.QueryString["query"]
单击该按钮时得到的结果是一个页面,内容如下:
所以,答案是肯定的。
I've just checked using a reduced test case:
action
ofdefault.aspx?query=1
and a submit button.Page_Load
to write outRequest.QueryString["query"]
The result I got when clicking on the button was a page that read:
So, the answer is yes.