坑爷了!!
request.getSession().getId()将返回服务器的会话ID(如果会话不存在,request.getSession()将创建它)。
request.getRequestedSessionId()是从cookie中获取的~~ ,如果浏览器没有cookie,或者客户端没有指定cookie,它就是空的。
真的太不靠谱了~~
mmp
getRequestedSessionId:没有指定,则为null~~
/**
* Returns the session ID specified by the client. This may not be the same
* as the ID of the current valid session for this request. If the client
* did not specify a session ID, this method returns <code>null</code>.
*
* @return a <code>String</code> specifying the session ID, or
* <code>null</code> if the request did not specify a session ID
* @see #isRequestedSessionIdValid
*/
public String getRequestedSessionId();
getSession:没有Session则创建
/**
* Returns the current session associated with this request, or if the
* request does not have a session, creates one.
*
* @return the <code>HttpSession</code> associated with this request
* @see #getSession(boolean)
*/
public HttpSession getSession();