Java HttpCookie setDomain() 方法

2025年3月22日 | 阅读1分钟

HttpCookie 类的 setDomian(String pattern) 方法用于指定 cookie 可以呈现的域。

 

语法

参数

上述方法只需要一个参数

  1. pattern - 表示一个字符串,其中包含 cookie 可见的域名称。

返回

不适用。

示例 1

输出

The domain name is given as: www.google.com

示例 2

输出

The first domain name is given as: www.localhost.com
The second domain name is given as: www.google.com 

示例 3

输出

The domain name is given as:  null 
下一个主题setHttpOnly() 方法