Cookie取值问题。 Cookie里不能保存中文,用UrlEncode编码一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不能用中文啊,用urlEncode如何写呢 问题:存到Cookie时用URLEncoder.encode("中文", "UTF-8"),但取出来时按"UTF-8"进行转码却不行(ISO-8859-1也不行),什么原因呢? 写Cookie: Cookie chineseCookie = new Cookie("chineseCookie", URLEncoder.encode("中文", "UTF-8")); chineseCookie.setMaxAge(36000); response.setCharacterEncoding("UTF-8"); response.addCookie(chineseCookie); 读Cookie: Cookie[] cookies = request.getCookies(); for (int i = 0; i < cookies.length; i++) { if ("chineseCookie".equals(cookies[i].getName())) { String temp = cookies[i].getValue(); temp = URLDecoder.decode(temp, "UTF-8"); System.out.println("chineseCookie : " + temp); //测试打印语句 } // writeHttpCookies cookie = new HttpCookies("MyCookieName");cookie.Value = Server.UrlEncode("王二");Response.Cookies.Add(cookie);// readHttpCookies cookie = Request.Cookies["MyCookieName"];string myName = Server.UrlDecode(cookie.Value); 我的多值Cookie,Cookie名不是中文的,值是中文的 If Request.Cookies("yj_user") IsNot Nothing Then Dim cookie As HttpCookie = Request.Cookies("yj_user") txtMan.Text = cookie.Values("username").ToString txtTel.Text = cookie.Values("userTel").ToString txtMail.Text = cookie.Values("useremail").ToString txtqq.Text = cookie.Values("userqq").ToString txtfb.Text = cookie.Values("userid").ToString '加入发布人id Panel1.Visible = True Else Panel1.Visible = False End If 请教2个面试问题 救急!!!!关于javascript问题 神奇的字符串赋值现象,大神大侠大牛快来看啊,能解决者100分相送啊 CSDN的这个功能怎么做的?求思路 如何把datagrid中textbox中的值传到后台去? 这是什么错误,如何解决(40分) 网上下了源码后怎么打开项目呀 ASP.NET中如何实现验证码 为什么在code-behind文件中可以使用page类的所有属性方法和事件? js拼接? 关于iframe的问题 急。用按钮动态添加网页里的上传窗口
Cookie chineseCookie = new Cookie("chineseCookie", URLEncoder.encode("中文", "UTF-8"));
chineseCookie.setMaxAge(36000);
response.setCharacterEncoding("UTF-8");
response.addCookie(chineseCookie);
读Cookie:
Cookie[] cookies = request.getCookies();
for (int i = 0; i < cookies.length; i++) {
if ("chineseCookie".equals(cookies[i].getName())) {
String temp = cookies[i].getValue();
temp = URLDecoder.decode(temp, "UTF-8");
System.out.println("chineseCookie : " + temp); //测试打印语句
}
HttpCookies cookie = new HttpCookies("MyCookieName");
cookie.Value = Server.UrlEncode("王二");
Response.Cookies.Add(cookie);// read
HttpCookies cookie = Request.Cookies["MyCookieName"];
string myName = Server.UrlDecode(cookie.Value);
Dim cookie As HttpCookie = Request.Cookies("yj_user") txtMan.Text = cookie.Values("username").ToString
txtTel.Text = cookie.Values("userTel").ToString
txtMail.Text = cookie.Values("useremail").ToString
txtqq.Text = cookie.Values("userqq").ToString
txtfb.Text = cookie.Values("userid").ToString '加入发布人id Panel1.Visible = True
Else
Panel1.Visible = False
End If