Query String Delimiters

2019-08-16 01:14发布

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

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

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?

标签: http url
1条回答
迷人小祖宗
2楼-- · 2019-08-16 02:13

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.

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.

查看更多
登录 后发表回答