您的位置:首页 > 运维架构 > Tomcat

tomcat7.0 cookie存中文信息出错

2015-04-17 11:15 351 查看
用中文用户名保存到cookie中出错

异常:java.lang.IllegalArgumentException: Control character in cookie value or attribute.

解决方法

String username=request.getParameter("username")

          if(cookie.getName().equals(username)){

               //使用cookie时解码

               String usrname= 
URLDecoder.decode(cookie.getValue(),"utf-8");


          }

}



另外:username如果乱码有可能是因为表单没有添加:method="POST"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: