获取到的sessionId 和request 为 null
protected Session retrieveSession(SessionKey sessionKey) throws UnknownSessionException { Serializable sessionId = getSessionId(sessionKey); if(sessionId == null) { System.out.println("sessionId 为 null "); } ServletRequest request = null; if(sessionKey instanceof WebSessionKey) { request = ((WebSessionKey) sessionKey).getServletRequest(); } if(request == null) { System.out.println("request 为 null"); } if(request != null && sessionId != null) { Session session = (Session)request.getAttribute(sessionId.toString()); if(session != null) {//在request中取 System.out.println("从request中取..."); return session; } } Session session = super.retrieveSession(sessionKey);//从redis中取 if(request != null && sessionId != null) request.setAttribute(sessionId.toString(), session); return session; }
因为sessionId 和request 为 null ,所以也就用不了request 去存取 session 。不知道什么原因?有人帮忙解决一下吗?