cookie存中文

 

 1 cookie存取:
 2 存: Cookie cookie = new Cookie("title",URLEncoder.encode("标题","utf-8"))
 3          cookie.setMaxAge(365 * 24 * 60 * 60);
 4           response.addCookie(cookie);
 5 取: Cookie[] cookies = request.getCookies();
 6          Cookie sCookie = null;
 7          String cookievalue="";
 8          for(int i = 0; i < cookies.length; i++){
 9                 sCookie = cookies[i];
10                 if(sCookie.getName()!=null&&sCookie.getName().equals("title"))
11                           cookievalues=URLDecoder.decode(sCookie.getValue(),"utf-8");
12          }

 

posted on 2014-05-28 22:39  wf110  阅读(1612)  评论(0编辑  收藏  举报