我已经在Sof 链接上找到了这个解决方案,但是我不得不从两个方面改变它:
我的代码如下所示:
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");如果我错了,请纠正我。先谢谢你
发布于 2011-06-25 02:33:00
在jsf 2.0中,您可以这样做:
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.getExternalContext().addResponseHeader("Set-Cookie", "; HTTPOnly");这样,就不需要对HttpServletResponse进行强制转换了。有关JSF的更多文档,请查看MyFaces文档索引。
https://stackoverflow.com/questions/6475196
复制相似问题