当前位置: 代码迷 >> 综合 >> javaweb中request.getSession(true)和request.getSession(false)的区别
  详细解决方案

javaweb中request.getSession(true)和request.getSession(false)的区别

热度:73   发布时间:2023-11-03 19:02:52.0
request.getSession(true):若存在会话则返回该会话,否则新建一个会话。
request.getSession(false):若存在会话则返回该会话,否则返回NULL

当向Session中存取登录信息时,一般建议:HttpSession session =request.getSession();

当从Session中获取登录信息时,一般建议:HttpSession session =request.getSession(false);

  相关解决方案