查询字符串分隔符 [英] Query String Delimiters

查看:58
本文介绍了查询字符串分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我知道您可以通过几个不同的字符将查询字符串中的参数分开

So I know you can separate your parameters in a query string through a couple different characters

(例如 www.example.com?foo=1&bar=2 或 www.example.com?foo1;bar=2)

(eg. www.example.com?foo=1&bar=2 or www.example.com?foo1;bar=2)

是否有除;"以外的字符和'&'可用于分隔查询参数?使用';'只是一般的编码实践吗?或&"或者是否有一些规定列出了我可以使用哪些字符?我知道在 RFC 3986 中保留字符包括

Are there any characters other than ';' and '&' that can be used to separate query parameters? Is it just general coding practice to use ';' or '&' or are there some regulations that list which characters I can use? I know in RFC 3986 the reserved characters include

";"|"/" |?"|":" |"@" |&"|=" |"+" |"$" |","

";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","

那么这是否意味着这些字符中的任何一个都可以用于分隔查询参数?

So does this mean that any of these characters can be used to separate query parameters?

推荐答案

查询字符串内容的格式不是 RFC 3986 (URI) 或 RFC 723* (HTTP) 的一部分;这是 HTML 表单工作方式的副作用.

The format of the query string contents isn't part of RFC 3986 (URIs) or RFC 723* (HTTP); it's a side effect of how HTML forms work.

因此,如果您的代码需要处理 HTML 表单,则您只能使用浏览器的功能.否则,理论上,您可以使用任何您想要的格式,只要它符合 RFC 3986 对查询"组件的定义即可.

So if your code needs to work with HTML forms, you are restricted to what browsers do. Otherwise, in theory, you can use any format you want, as long as it's consistent with RFC 3986's definition of the "query" component.

这篇关于查询字符串分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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