我在 Sof链接上找到了这个解决方案, 但我不得不从两个原因改变它:
- 没有 .getFacesContext() 函数
- 我没有特定的 cookie 文件(见 ourcookiename=yourcookievalue 行)
我的代码如下所示:
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.addHeader("Set-Cookie", "; HTTPOnly");
原始代码
FacesContext facesContext = FacesContext.getCurrentInstance().getFacesContext();
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.addHeader("Set-Cookie", "yourcookiename=yourcookievalue; HTTPOnly");
如果我错了,请纠正我。先感谢您