The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white s " /> 亚洲一区av,九九久久电影,精品国产乱码久久久久久浪潮

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

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

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
在另外一篇關于JavaScript操作cookie的文章中提到:

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

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

JavaScript技術不要在cookie中使用特殊字符的原因分析,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 辛集市| 甘南县| 乌苏市| 涞源县| 光泽县| 秭归县| 太谷县| 田阳县| 平乐县| 新安县| 武义县| 台北市| 平乐县| 蛟河市| 阳曲县| 灵山县| 吉林市| 商丘市| 肃北| 拜泉县| 海晏县| 德惠市| 龙泉市| 确山县| 靖江市| 衡阳市| 宜兴市| 聊城市| 响水县| 军事| 嘉黎县| 宣武区| 新津县| 浮梁县| 夏河县| 武陟县| 成都市| 景东| 左云县| 金山区| 象山县|