tomcat踩坑记之----cookie处理机制



java.lang.IllegalArgumentException: An invalid domain [.oschina.net] was specified for this cookie
	org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateDomain(Rfc6265CookieProcessor.java:198)
	org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:145)
	org.apache.catalina.connector.Response.generateCookieString(Response.java:1019)
	org.apache.catalina.connector.Response.addCookie(Response.java:967)
	org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
	com.vrv.im.filter.SSOFilter.addCookie(SSOFilter.java:298)
	com.vrv.im.filter.SSOFilter.doFilter(SSOFilter.java:165)

因为我本地采用高版本的tomcat8,


tomcat8中content.xml中CookieProcessor默认为Rfc6265CookieProcessor

Rfc6265CookieProcessor 使用的domain规则如下
1、必须是1-9、a-z、A-Z、. 、- (注意是-不是_)这几个字符组成

2、必须是数字或字母开头 (所以以前的cookie的设置为.i5a6.com 的机制要改为 i5a6.com 即可)

3、必须是数字或字母结尾

解决方法:

添加:<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />


然后就ok了


undefined



0
0

暂无评论