Java HttpCookie domainMatches() 方法

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

HttpCookie 类的 domainMatches(String domain, String host) 方法用于检查一个主机名是否属于一个域。

语法

参数

上述方法需要两个参数

  • domain - 表示要检查主机名的域名。
  • host - 表示被检查的主机名。

返回

如果域名匹配,上述方法返回 true。否则,返回 false。

示例 1

输出

Tests whether a host name lies in the domain or not: false

示例 2

输出

Tests whether a host name lies in the domain or not: true

示例 3

输出

Tests whether the first host name lies in the first domain or not: true
Tests whether the second host name lies in the second domain or not: false
下一主题equals() 方法