request.getSession()、request.getSession(false)和request.getSession(true)的区别

request.getSession()、request.getSession(false)和request.getSession(true)的区别:

在J2EE的API文档中关于HttpSession getSession(boolean create)的说明是:
Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.
而对于HttpSession getSession()的说明是:
Returns the current session associated with this request, or if the request does not have a session, creates one.

由此可见:request.getSession()和request.getSession(true)是等价的。

你可能感兴趣的:(session)