Cookie read and write issue- jQuery to JSP

感情迁移 提交于 2020-01-15 12:40:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!