我做本地测试用只
public static void setCookieValue(String name , String value , Integer age , HttpServletResponse res){
Cookie cc = new Cookie(name , value);
if(age != null && age.intValue() != 0) {
cc.setMaxAge(age);
// cc.setDomain("axxxx.com");
// cc.setPath("/");
}
res.addCookie(cc);
}
当只setMaxAge的时候,可以生成COOKIE,但是如果setDomain和setPath加入的时候,就无法生成COOKIE,我用的是localhost:8080/项目名,进行测试,请问如何生成domain和path呢?
public static void setCookieValue(String name , String value , Integer age , HttpServletResponse res){
Cookie cc = new Cookie(name , value);
if(age != null && age.intValue() != 0) {
cc.setMaxAge(age);
// cc.setDomain("axxxx.com");
// cc.setPath("/");
}
res.addCookie(cc);
}
当只setMaxAge的时候,可以生成COOKIE,但是如果setDomain和setPath加入的时候,就无法生成COOKIE,我用的是localhost:8080/项目名,进行测试,请问如何生成domain和path呢?
哈哈! 权限问题,跨域的cookie当然不允许了。
hosts增加一行
127.0.0.1 axxxxx.com localhost 就可以了