jetty在集群环境中使用时,浏览器中的sessionId和后台代码中获得的sessionId可能存在不一致的情况,
部署结构为:apache httpd2.2 + 2个jetty7.4
jetty.xml中配置了sessionIdManager:
<Set name="sessionIdManager"> <New class="org.eclipse.jetty.server.session.HashSessionIdManager"> <Set name="workerName">jetty_instance1</Set> </New> </Set>
其中的workerName类似于tomcat中的jvmRoute,用于集群中的请求分发(session粘滞)
浏览器中获得的JSESSIONID的值带有 workerName后缀,例如:
JSESSIONID tas1lktlh90nwcqru3sk1ev2b2z0.jetty_instance1
而后台获得的sessionId则不带workerName后缀
String sid = request.getSession().getId();
System.out.println(sid);
// 获得的sessionId为:
tas1lktlh90nwcqru3sk1ev2b2z0
希望jetty尽快修改这个bug