`
a25765339
  • 浏览: 60757 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

关于Cookie中不过滤“=”号的方法

 
阅读更多
当用cookie.getValue()方法获取Cookie的值时,结果遇到"="号时就会自动截断,后面的值就取不到了。这是因为tomcat中的Cookie信息默认是不允许有特殊字符的,所以有特殊字符时就会取不到。这时你可以在tomcat中的conf文件夹下的catalina.properties文件中添加如下代码:
org.apache.tomcat.util.http.ServerCookie.ALLOW_EQUALS_IN_VALUE=true
当添加这段代码后,你会发现你用cookie.getValue()就可以取到包含"="的cookie的值了。




----------------------------------------------------------------------

Tomcat truncating cookies with = values

Starting with Tomcat 6.0.18 and in Tomcat 7.x any cookie containing a “=” will be truncated. Where you would expect your cookie to hold all values, e.g. “value1=myname&value2=password” you will only be able to retrieve the “value1=”.

This is because Tomcat now adheres to the cookie spec more tightly than previous versions. If you are in control of the cookie you might be able to change it and work around this. If not, then you can can change the settings within the catalina.properties file by appending the following two settings:

org.apache.tomcat.util.http.ServerCookie.ALLOW_EQUALS_IN_VALUE=true
org.apache.tomcat.util.http.ServerCookie.ALLOW_HTTP_SEPARATORS_IN_V0=true
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics