<<javaWeb王者归来>>上面写getSession()在session不存在的情况下会返回null,但是查看ServletAPI文档可以看到
依据api文档
HttpSession | getSession() Returns the current session associated with this request, or if the request does not have a session, creates one. |
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. |
getSession()应该和getSession(true)等效的,肯定不会返回null
getSession(false)有可能返回null
但是还是有一点点的怀疑,打算以后以英文书籍为标准,很多中国作者都是苦鬼互相坑害的,或者只是为了显摆和挣钱,不好意思前几天写重了