如何在查询字符串中传递多个参数 [英] How to pass multiple parameters in a querystring

查看:36
本文介绍了如何在查询字符串中传递多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将三个值作为参数传递,例如 strIDstrNamestrDate.

I have three values which I have to pass as parameters for e.g., strID, strName and strDate.

我想将这三个参数重定向到 Response.Redirect() 中的另一个页面.谁能提供正确的查询字符串?

I want to redirect these three parameters to another page in Response.Redirect().Can anybody provide me with the correct querystring?

推荐答案

Query_string

(以下是维基百科条目链接部分的文本.)

(Following is the text of the linked section of the Wikipedia entry.)

包含查询字符串的典型 URL 如下:

A typical URL containing a query string is as follows:

http://server/path/program?query_string

当服务器收到对此类页面的请求时,它会运行一个程序(如果配置为这样做),将未更改的 query_string 传递给该程序.问号用作分隔符,不是查询字符串的一部分.

When a server receives a request for such a page, it runs a program (if configured to do so), passing the query_string unchanged to the program. The question mark is used as a separator and is not part of the query string.

网页中的链接可能有一个包含查询字符串的 URL,但是,HTML 定义了 Web 浏览器生成查询字符串的三种方式:

A link in a web page may have a URL that contains a query string, however, HTML defines three ways a web browser can generate the query string:

  • 通过 ... 元素的网络表单
  • 通过带有构造的元素上的 ismap 属性的服务器端图像映射
  • 通过现已弃用的元素进行索引搜索

查询字符串的主要用途是包含 HTML 表单(也称为 Web 表单)的内容.特别是,当提交包含字段 field1、field2、field3 的表单时,字段的内容被编码为查询字符串,如下所示:

The main use of query strings is to contain the content of an HTML form, also known as web form. In particular, when a form containing the fields field1, field2, field3 is submitted, the content of the fields is encoded as a query string as follows:

field1=value1&field2=value2&field3=value3...

  • 查询字符串由一系列字段值对组成.
  • 在每一对中,字段名称和值用等号分隔.如果值为空字符串,则可以省略等号.
  • 对系列由与号&"隔开(或分号,';' 表示嵌入在 HTML 中且不是由 ... 生成的 URL;见下文).虽然没有明确的标准,但大多数 Web 框架都允许将多个值与单个字段相关联:

field1=value1&field1=value2&field1=value3...

对于表单的每个字段,查询字符串包含一对字段=值.Web 表单可能包含用户不可见的字段;提交表单时,这些字段包含在查询字符串中

For each field of the form, the query string contains a pair field=value. Web forms may include fields that are not visible to the user; these fields are included in the query string when the form is submitted

该约定是 W3C 推荐的.W3C 建议所有 Web 服务器都支持除与符号分隔符之外的分号分隔符 [6],以允许在 HTML 文档中的 URL 中使用 application/x-www-form-urlencoded 查询字符串,而无需实体转义与符号.

This convention is a W3C recommendation. W3C recommends that all web servers support semicolon separators in addition to ampersand separators[6] to allow application/x-www-form-urlencoded query strings in URLs within HTML documents without having to entity escape ampersands.

从技术上讲,表单内容仅在表单提交方法为 GET 时编码为查询字符串.提交方式为POST时默认使用相同的编码,但结果不作为查询字符串发送,即不添加到表单的action URL中.相反,该字符串作为 HTTP 请求的正文发送.

Technically, the form content is only encoded as a query string when the form submission method is GET. The same encoding is used by default when the submission method is POST, but the result is not sent as a query string, that is, is not added to the action URL of the form. Rather, the string is sent as the body of the HTTP request.

这篇关于如何在查询字符串中传递多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆