Java HttpCookie getPath() 方法

2025 年 3 月 22 日 | 阅读需 2 分钟

HttpCookie 类的 getPath() 方法用于返回浏览器返回 cookie 的服务器路径。该 cookie 将在给定服务器的所有子路径中可见。

语法

参数

不适用。

返回

上述方法用于返回一个指定包含 servlet 名称的路径的字符串。例如:/catalog

示例 1

输出

The path is given as: 189.144.22.5/user/index.html

示例 2

输出

The first path is given as: 189.144.22.5/user/index1.html
The second path is given as: 145.132.19.6/client/index2.html

示例 3

输出

The path is given as: null
下一个主题getPortList() 方法