java - HTTP 请求 : ';' character in the request URL

标签 java .net http http-headers

在许多网站(特别是 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/

相关文章:

java - 如何找到对象分配的总内存

java - 不寻常的 "static"方法声明

c# - 有条件地显示/隐藏 Windows 表单元素

c# - 基本泛型接口(interface)上的扩展方法

javascript - 如何减少聊天​​的 AJAX 请求数量?

java - 如何读取 HttpServletReponses 输出流?

angular - Rxjs 可观察间隔和 Angular2 HTTP : wait for response

java - 如何在命令行上避免Java系统属性?

.NET Repeater - 自定义服务器验证

简单 Java 程序的 Javascript 包装器