Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

SpringBoot request.getSession()几种获取情况之间的差异

三种情况如下

HttpSession session = request.getSession();

HttpSession session = request.getSession(true);

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;

具体的使用场景

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

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

上一篇 Spring AOP 五大通知类型
下一篇 Redlock:Redis分布式锁最牛逼的实现