现实中我们经常会遇到以下3中用法:HttpSession session = request.getSession(); HttpSession session = request.getSession(true); HttpSession session = request.getSession(false); HttpServletRequest.getSession(TURE)等同于HttpServletRequest.getSession()HttpServletRequest.getSession(假)等同于如果当前会话没有就为空; 当向会话中存取登录信息时,一般建议:HttpSession session = request.getSession(); 当从会话中获取登录信息时,一般建议:HttpSession session = request.getSession(false);
关于request.getSession(true/false/null)的区别
最新推荐文章于 2022-05-23 00:29:52 发布