request.getSession() will return the current session and if one does not exist, a new session will be cretaed.
request.getSession(true) will return the current session if one exists, if one doesn't exits a new one will be created.
So there is actually no difference between the two methods.
HOWEVER, if you use request.getSession(false), it will return the current session if one exists and if one DOES NOT exist a new one will NOT be cretaed.
request.getSession(true) will return the current session if one exists, if one doesn't exits a new one will be created.
So there is actually no difference between the two methods.
HOWEVER, if you use request.getSession(false), it will return the current session if one exists and if one DOES NOT exist a new one will NOT be cretaed.
本文解析了在Java Web开发中,使用request.getSession方法的不同形式及其行为差异。重点介绍了getSession方法如何根据参数true或false来决定是否创建新的会话。
2805

被折叠的 条评论
为什么被折叠?



