在许多网站(特别是 gmail、yahoo 或 hotmail)中,您会注意到 URL
后面是这样的:yahoo.com/abc/bcd.html;_x=12323;_y=2322;
这些 _x 和 _y 参数是什么?如何在服务器端代码中访问它们?
最佳答案
它们是 URL 中的参数(与查询字符串不同),this article有一个很好的讨论,包括这个有用的图表:
<scheme>://<username>:<password>@<host>:<port>/<path>;<parameters>?<query>#<fragment>
请注意,它们不是 Java EE 中使用的意义上的“参数”ServletRequest#getParameter
等等(当他们说“参数”时,他们指的是查询字符串或 POST 参数,它们是不同的)。
这是在 §3.3 of RFC 2396 中定义的:
The path may consist of a sequence of path segments separated by a single slash "/" character. Within a path segment, the characters "/", ";", "=", and "?" are reserved. Each path segment may include a sequence of parameters, indicated by the semicolon ";" character. The parameters are not significant to the parsing of relative references.
(为避免疑义:上面的术语“路径”不包括查询字符串,请参阅 beginning of §3。)
RFC 2396 已被 RFC 3986 废弃,不过,这amends the above明显地:
Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents. For example, the semicolon (";") and equals ("=") reserved characters are often used to delimit parameters and parameter values applicable to that segment. The comma (",") reserved character is often used for similar purposes. For example, one URI producer might use a segment such as "name;v=1.1" to indicate a reference to version 1.1 of "name", whereas another might use a segment such as "name,1.1" to indicate the same. Parameter types may be defined by scheme-specific semantics, but in most cases the syntax of a parameter is specific to the implementation of the URI's dereferencing algorithm.
关于java - HTTP 请求 : ';' character in the request URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11611505/