cookie中文问题

来源:互联网 发布:开淘宝店好还是天猫好 编辑:程序博客网 时间:2024/05/19 22:07

当cookie的内容含有中文时会报错:Control character in cookie value, consider BASE64 encoding your value

解决方案:创建Cookie时Cookie cookieUsername=new Cookie("username", URLEncoder.encode(username,"utf-8"));

               取Cookie时 username=URLDecoder.decode(cookie.getValue(), "utf-8");

原创粉丝点击