URL location.search 的语法或格式
Syntax or format for URL location.search
是否为 URL 的“搜索”部分指定了 syntax/format?
像?id!=123&(name=foo|name=bar)
这样使用可以吗?
这会在 javascript/Spring 框架中工作还是我需要编写自定义解析器?
Is there a syntax/format specified for the "search" part of the URL?
是的。 query
部分的产生式规则在RFC 3986. I often find it is easier to look at the entire collection of production rules, which are grouped together in appendix A
中指定
query = *( pchar / "/" / "?" )
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded = "%" HEXDIG HEXDIG
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
Is it alright to use like ?id!=123&(name=foo|name=bar)?
VERTICAL LINE不符合标准;所以你应该对它进行百分比编码
?id!=123&(name=foo%7Cname=bar)
应该没问题。
如果这在任何地方都“有效”,我会感到震惊。正是出于这个原因,我们制定了标准。
是否为 URL 的“搜索”部分指定了 syntax/format?
像?id!=123&(name=foo|name=bar)
这样使用可以吗?
这会在 javascript/Spring 框架中工作还是我需要编写自定义解析器?
Is there a syntax/format specified for the "search" part of the URL?
是的。 query
部分的产生式规则在RFC 3986. I often find it is easier to look at the entire collection of production rules, which are grouped together in appendix A
query = *( pchar / "/" / "?" )
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded = "%" HEXDIG HEXDIG
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
Is it alright to use like ?id!=123&(name=foo|name=bar)?
VERTICAL LINE不符合标准;所以你应该对它进行百分比编码
?id!=123&(name=foo%7Cname=bar)
应该没问题。
如果这在任何地方都“有效”,我会感到震惊。正是出于这个原因,我们制定了标准。