1.HttpSession session = request.getSession();
2.HttpSession session = request.getSession(true);
3.HttpSession session = request.getSession(false);
getSession(boolean create)意思是返回当前reqeust中的HttpSession ,
如果当前reqeust中的HttpSession 为null,当create为true,就创建一个新的Session,否则返回null;
HttpServletRequest.getSession(ture)等同于 HttpServletRequest.getSession()
HttpServletRequest.getSession(false)等同于 如果当前Session没有就为null;
2.HttpSession session = request.getSession(true);
3.HttpSession session = request.getSession(false);
getSession(boolean create)意思是返回当前reqeust中的HttpSession ,
如果当前reqeust中的HttpSession 为null,当create为true,就创建一个新的Session,否则返回null;
HttpServletRequest.getSession(ture)等同于 HttpServletRequest.getSession()
HttpServletRequest.getSession(false)等同于 如果当前Session没有就为null;
本文解析了HTTP请求中getSession方法的不同调用方式及含义。详细说明了getSession(boolean create)参数的作用:当Session不存在时,若create为true,则创建新的Session;反之则返回null。此外,还对比了getSession(true)与getSession(false)的区别。
2810

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



