cookie 问题
list:7, itemlist.size = 1 arr.length = 1
list:3, itemlist.size = 1 arr.length = 1
list:6, itemlist.size = 1 arr.length = 1
点三次cokie list字符串没连起来,代码和视频一样,怎么解决
list:7, itemlist.size = 1 arr.length = 1
list:3, itemlist.size = 1 arr.length = 1
list:6, itemlist.size = 1 arr.length = 1
点三次cokie list字符串没连起来,代码和视频一样,怎么解决
2016-11-05
String list =""; //从客户端获得Cookies集合 Cookie[] cookies = request.getCookies(); //遍历这个Cookies集合 if(cookies!=null&&cookies.length>0) { for(Cookie c:cookies) { if(c.getName().equals("ListViewCookie")) { list = c.getValue(); } } } list+=request.getParameter("id")+","; //如果浏览记录超过1000条,清零. String[] arr = list.split(","); if(arr!=null&&arr.length>0) { if(arr.length>=1000) { list=""; } } Cookie cookie = new Cookie("ListViewCookie",list); response.addCookie(cookie);
举报