相关疑难解决方法(0)

如何在JSF中添加cookie?

当我添加如下cookie时:

FacesContext.getCurrentInstance().getExternalContext().addResponseCookie("Test", "Test", null);
Run Code Online (Sandbox Code Playgroud)

然后它运行良好,但cookie成为最大年龄为的会话cookie -1.

当我尝试如下:

Map<String, Object> properties = new HashMap<>();
properties.put("domain", "test");
properties.put("maxAge", 31536000);
properties.put("secure", false); 
properties.put("path","/");
FacesContext.getCurrentInstance().getExternalContext().addResponseCookie("Test", "Test", properties);
Run Code Online (Sandbox Code Playgroud)

然后我在任何地方都看不到cookie.我不明白为什么.

我正在使用Tomcat 7.

cookies jsf-2

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

cookies ×1

jsf-2 ×1