Jetty中提供了两个接口对seesion进行管理,SessionManager、SessionIdManager;且有对应的提供了两个抽象类,AbstractSessionManager,AbstractSessionIdManager;
具体怎么实现,上代码:
(1)首先一个客户端的request请求到达服务器,通过调用request.getSession调用SessionManager生成一个新的sessionId:
public HttpSession getSession(boolean create)
{
if (_session != null)
{
if (_sessionManager != null && !_sessionManager.isValid(_session))
_session = null;
else
return _session;
}
if (!create)
return null;
if (_sessionManager == null)
throw new IllegalStateException("No SessionManager");
_session = _sessionManager.newHttpSession(this);
HttpCookie cookie = _sessionManager.getSessionCookie(_session,
Session 创建ID的规则
最新推荐文章于 2024-04-01 09:54:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)