我有个问题:
C:\Program Files\IBM\SDP\runtimes\base_v7\bin\migration
中的迁移工具将应用程序从WAS6.1迁移到WAS7.0Cookie
来从用户获得分区。Cookie
正在被创建,但由于一个不知道Cookie
没有被放入HttpServletResponse
的原因,所以当我试图检索Cookie
的值时,它说它是null
。下面是用于执行此操作的代码片段:
public static void setDivisionCookie( String div, HttpServletResponse res ){
Cookie cookie = new Cookie(USER_DIVISION_COOKIE_NAME, div);
cookie.setMaxAge(Integer.MAX_VALUE);
cookie.setPath("/");
res.addCookie( cookie );
}
我不得不说应用程序是用Struts运行的(这是我使用的struts-1.2.9
、struts2-core-2.1.8.1
、struts-taglib-1.3.8
的jar)
发布于 2013-08-07 10:23:00
每个web应用程序在servlet上下文路径下获取/放置cookie。例如
cookie.setPath(request.getContextPath());
https://stackoverflow.com/questions/18110376
复制