美文网首页
session.getId()和request.getReque

session.getId()和request.getReque

作者: 萧萧飞叶 | 来源:发表于2019-04-13 00:44 被阅读0次

坑爷了!!


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();

https://stackoverflow.com/questions/38797066/request-getsession-getid-vs-request-getrequestedsessionid

相关文章

网友评论

      本文标题:session.getId()和request.getReque

      本文链接:https://www.haomeiwen.com/subject/gbukwqtx.html