最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

不要在cookie中使用特殊字符的原因分析

 更新時間:2010年07月13日 21:05:10   作者:  
參數(shù)name需要遵循規(guī)范RFC2109,也就是說name參數(shù)只能包含字母或者數(shù)字,不能包含逗號、分號、空格及美元符號。cookie的name屬性設(shè)置之后不能被修改。
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類構(gòu)造函數(shù)的說明,重點對name和value可以使用的字符進(jìn)行了介紹。

參數(shù)name需要遵循規(guī)范RFC2109,也就是說name參數(shù)只能包含字母或者數(shù)字,不能包含逗號、分號、空格及美元符號。cookie的name屬性設(shè)置之后不能被修改。

參數(shù)value可以是服務(wù)端設(shè)置的任意值,該值可以通過setValue方法進(jìn)行重新設(shè)置。

然后實際情況并非如此!!

(1)value值中不能包含逗號,如果value中包含逗號則程序無法編譯。

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

Cookie pwdCookie = new Cookie("option", "block1,block2");
則異常如下:

java.lang.IllegalArgumentException: block1,block2
在另外一篇關(guān)于JavaScript操作cookie的文章中提到:

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

總之,盡量不要在cookie中使用特殊字符。

相關(guān)文章

最新評論

八宿县| 台前县| 贵溪市| 乌兰浩特市| 青铜峡市| 东至县| 遂川县| 策勒县| 平乐县| 米泉市| 庆云县| 靖江市| 禹城市| 曲阳县| 广宗县| 日喀则市| 高阳县| 阳朔县| 和硕县| 垦利县| 洛扎县| 手机| 古丈县| 天峨县| 如东县| 乌审旗| 呼图壁县| 南江县| 资源县| 疏附县| 兴海县| 德格县| 闽清县| 南投市| 达日县| 东城区| 舞阳县| 平山县| 鄯善县| 嘉鱼县| 宜章县|