tamcat8.5.30在启动项目的时候,报An invalid domain [.xx.com] was specified for this cookie异常,在网上找到了相关解释,原因是:tomcat8.5及以上CookieProcessor使用的是org.apache.tomcat.util.http.Rfc6265CookieProcessor,而tomcat8.0及以下使用的是org.apache.tomcat.util.http.LegacyCookieProcessor。
解决方案:
1)修改tomcat配置:tomcat的conf/context.xml 文件中,
<Context>
...
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
...
</Context>
2) 修改代码:
tomcat8.5及以上版本的时候,设置cookie配置domain的时候,不要在域名前加“.”,如cookie.setDomain("xx.com"),8.0及以前的版本加“.”如:cookie.setDomain(".xx.com")
记录一下这个问题。