日期:2014-05-16 浏览次数:20371 次
第一步:写入cookie时先进行编码
??????????? Cookie cookie=new Cookie("groupMembersList",URLEncoder.encode? (groupMembersList,"GBK"));???????????????????????????????????????? //默认为临时Cookie,MaxAge<0
??????? ?//cookie.setMaxAge(-1);
??????? response.addCookie(cookie);
?
第二步:读取cookie再进行解码
?????? <%
??????????? ?Cookie[] cookies=request.getCookies();
??????????? ?for(Cookie cookie:cookies){
?????????????????? ?if(cookie.getName().equalsIgnoreCase("groupMembersList"))
?????????? ??request.setAttribute("group",URLDecoder.decode(cookie.getValue(),"GBK"));???
????????? ??}
????? %>
???? <c:out value="${requestScope.group }"/>