cookie分号后面没有值_尽量不要在cookie中使用特殊字符

public Cookie(java.lang.String name,java.lang.String value)

Constructs a cookie with a specified name and value.

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie’s name cannot be changed after creation.

The value can be anything the server chooses to send. Its value is probably of interest only to the server. The cookie’s value can be changed after creation with the setValue method.

By default, cookies are created according to the Netscape cookie specification. The version can be changed with the setVersion method.

以上是java API文档中对Cookie类构造函数的说明,重点对name和value可以使用的字符进行了介绍。

参数name需要遵循规范RFC2109,也就是说name参数只能包含字母或者数字,不能包含逗号、分号、空格及美元符号。cookie的name属性设置之后不能被修改。

参数value可以是服务端设置的任意值,该值可以通过setValue方法进行重新设置。

然后实际情况并非如此!!

(1)value值中不能包含逗号,如果value中包含逗号则程序无法编译。

如果value中包含逗号,如下:

Cookie pwdCookie = new Cookie(“option”, “block1,block2”);

则异常如下:

java.lang.IllegalArgumentException: block1,block2

在cookie 的名或值中不能使用分号(;)、逗号(,)、等号(=)以及空格。

总之,尽量不要在cookie中使用特殊字符。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值