代码在windows下正常运行,部署到liunx下后cookie就获取不到了,很是奇怪
写入
Cookie cookie = new Cookie("CERLOGIN", "ABCD");
cookie.setMaxAge(3600*24);
cookie.setPath("/");
response.addCookie(cookie);
获取
Cookie[] cookies = request.getCookies();
System.out.println("遍历cookie");
Cookie cookie = null;
if(cookies != null){
for(int i=0;i<cookies.length;i++){
if(cookies[i].getName().equals("CERLOGIN") && !Tool.nvl(cookies[i].getValue()).equals("")){
cookie = cookies[i];
}
}
}
if(cookie != null)
System.out.println(cookie.getValue());
------解决方案--------------------------------------------------------
cookie.setPath("/");这句