这段保存cookie的代码为什么用中文字符保存不了哪,在线等 又是你。你想想你cookies是用在登录时候的,换个角度说,就是注册时注册用户名时你会用中文吗?你看过那个网站登录用户名会用中文的呢?所以你这个是不必要理会它中文出错的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 刚好上个项目用到了这块,我的解决方案是对中文编码要不就报错new Cookie("username",URLEncoder.encode(username));客户端取的时候用javascript的decodeURI解码就可以了 用<% new Cookie("username",URLEncoder.encode("中文","UTF-8")); %><%=URLDecoder.decode(cookies.getValue(),"UTF-8") %>貌似好一些吧,因为它针对转换成指定的字符串 request.setCharacterEncoding("gbk"); String username = request.getParameter("username"); username = String(username .getBytes("iso-8859-1"),"gbk"); 然后再使用 username... cookie好像不支持直接存中文,我记得以前做的东西存中文就报错的。2楼是正解,我当时就那么解决的 google浏览器无法返回 【cant connect to mysql server 10055】 问题 JSP中的过滤器问题。。。 【提问】javabean连接Mysql数据库问题 新手渴求:oracle存储过程(要带参数的)创建代码,及jsp中调用该存储过程的代码。 JSP怎么处理中文字符问题,急,在线等呀!!! 求救!!怎样从 session 中读取属性值??? 错在哪了?????????????????????? 刚改版,不知怎么用,试试!:) SSH框架中最近遇到的error。 如何为Flash超链接 简单的问题
new Cookie("username",URLEncoder.encode(username));客户端取的时候用javascript的decodeURI解码就可以了
<%=URLDecoder.decode(cookies.getValue(),"UTF-8") %>貌似好一些吧,因为它针对转换成指定的字符串
String username = request.getParameter("username");
username = String(username .getBytes("iso-8859-1"),"gbk");
然后再使用 username...