HTTP GET请求中的多参数问题

7
4个回答

7

不能再次使用问号“?”,问号“?”应该表示参数列表的开始,而和号“&”应该分隔参数。

来自RFC 3986

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

来自RFC 1738

An HTTP URL takes the form:

http:// <host> : <port> / <path> ? <searchpart>

where <host> and <port> are as described in Section 3.1. If :<port> is omitted, the port defaults to 80. No user name or password is allowed. <path> is an HTTP selector, and <searchpart> is a query string. The <path> is optional, as is the <searchpart> and its preceding "?". If neither <path> nor <searchpart> is present, the "/" may also be omitted.

Within the <path> and <searchpart> components, "/", ";", "?" are reserved. The "/" character may be used within HTTP to designate a hierarchical structure.

这里描述了搜索部分/查询部分


5

1

application/x-www-form-urlencoded

这是默认的内容类型。使用此内容类型提交的表单必须按以下方式进行编码:

  1. 控件名称和值都需要进行转义。空格字符将被替换为+,然后保留字符将按[RFC1738]第2.2节所述进行转义:非字母数字字符将被替换为%HH,即一个百分号和两个十六进制数字,表示该字符的ASCII代码。换行符表示为“CR LF”对(即%0D%0A)。
  2. 控件名称/值按它们在文档中出现的顺序列出。名称与值之间用=分隔,名称/值对之间用&分隔。

application/x-www-form-urlencoded


0

如上所述,再次使用它是无效的。但是,如果您将“?”字符作为参数值的一部分,则可以将其编码为%63(就像空格字符被编码为%20一样)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接