我在 this issue 中运行,如何在 Jetty 8 中通过代码设置 session cookie 名称?
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
sessionHandler = new SessionHandler();
sessionHandler.getSessionManager().setSessionCookie("JSESSIONID_"+runningPort);
context.setSessionHandler(sessionHandler);
是错误的,在 Jetty8 中 SessionManager
setSessionCookie(String)
被移除了。
最佳答案
这里是答案:
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
SessionManager sm = new HashSessionManager();
((HashSessionManager)sm).setSessionCookie("JSESSIONID_"+activity.WEB_SERVER_PORT);
context.setSessionHandler(new SessionHandler(sm));
关于java - 以编程方式设置 Jetty session cookie 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24017645/