最新国产好看的视频,伊人天堂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)文章

最新評論

防城港市| 宝坻区| 克什克腾旗| 建平县| 广河县| 积石山| 霍州市| 耒阳市| 南陵县| 蕲春县| 芒康县| 康乐县| 信宜市| 浑源县| 阿拉善左旗| 建瓯市| 安溪县| 长兴县| 莱西市| 新化县| 平远县| 泰顺县| 孟连| 廊坊市| 镇沅| 崇仁县| 杭锦后旗| 越西县| 惠东县| 皮山县| 石渠县| 宾川县| 东兰县| 丰都县| 阿拉善右旗| 平乡县| 九台市| 祁阳县| 林州市| 景宁| 仁寿县|