Request从几个集合取数据是有顺序的,从前到后的顺序依次是 QueryString,Form,最后是ServerVariables。Request对象按照这样的顺序依次搜索这几个集合中的变量,如果有符合的就中止,后面的就不管了。


假设有个页面 test.asp?id=111
这里我们的页面是用GET的方法.这时用request.querystring("id")与request("id")是一样得,应该如果不指定REQUEST得集合,首先就会从Querystring搜索.

而如果我们的页面是用的是POST的方法发送数据给test.asp,那么用request.querystring("id")是不行的了(他只能取GET),而要用request.from("id"),而如果还用request("id")他也能取到数据,但先检测QUERYSTRING的值,显然速度就慢了.

下面是个检测的例子你可以看看:
<%
If Request("submit")<>"" then
Response.Write "直接取:"& Request("username") & "<br>"
Response.Write "取Get:" & Request.QueryString("username") & "<br>"
Response.Write "取Post:" & Request.Form("username") & "<br>"
End if
%>
<form name=form1 action="" method=post>
<input type=test name="username" value="postuser">
<input type=submit name="submit" value="test">
</form>

养成好的习惯,记得在request后面加上集合的名字.

相关文章:

  • 2022-02-25
  • 2021-09-26
  • 2022-12-23
  • 2022-01-02
  • 2021-12-11
  • 2022-12-23
  • 2021-06-29
猜你喜欢
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-01-11
  • 2021-07-30
相关资源
相似解决方案