问题
using jQuery cookie plugin I create cookie:
$.cookie('uom', '1-23-235(K)');
When I read it from JSP, it Return me only the following
1-23-235
and if I remove parentheses while creating cookies, such as
$.cookie('uom', '1-23-235 K');
then there is no problem! All working is fine.
How can I overcome this because user can enter any symbol like parentheses
回答1:
Try escaping (aka URL-encoding) the strings you set as cookies:
On the JS side:
escape(cookie);
On the Java side:
String result = URLDecoder.decode(cookie, "UTF-8");
来源:https://stackoverflow.com/questions/10765172/cookie-read-and-write-issue-jquery-to-jsp