Session的方法getSession() 与 getSession(boolean para)区别
getSession(boolean para)返回当前http会话,如果不存在,则创建一个新的会话
getSession() 调用getSession(true)的简化版
【官方解释】
getSession
public HttpSession getSession(boolean create)
Returns
the current HttpSession associated with this request or, if if there is
no current session and create is true, returns a new session.
If create is false and the request has no valid HttpSession, this method returns null.
To
make sure the session is properly maintained, you must call this method
before the response is committed. If the container is using cookies to
maintain session integrity and is asked to create a new session when the
response is committed, an IllegalStateException is thrown.
Parameters: true - to create a new session for this request if necessary; false to return null if there's no current session
Returns: the HttpSession associated with this request or null if create is false and the request has no valid session
译:
getSession(boolean create)意思是返回当前reqeust中的HttpSession ,如果当前reqeust为false,并且当前没有HttpSession,那么久返回为null,如果create为true,没有Session时就会创建一个新的Session;
简而言之:
HttpServletRequest.getSession(ture) 等同于 HttpServletRequest.getSession()
HttpServletRequest.getSession(false) 等同于 如果当前Session没有就为null;
Session的方法getSession() 与 getSession(boolean para)区别的更多相关文章
- 【转】于request.getSession(true/false/null)的区别
http://blog.csdn.net/gaolinwu/article/details/7285783 关于request.getSession(true/false/null)的区别 一.需求原 ...
- hibernate4中使用Session doWork()方法进行jdbc操作(代码)
Hibernate3.3.2版本中getSession().connection()已被弃用,hibernate4中官方推荐使用Session doWork()方法进行jdbc操作 首先看看Work接 ...
- 基于redis的处理session的方法
一个基于redis的处理session的方法,如下. <?php class Session_custom { private $redis; // redis实例 private $prefi ...
- 如何使用数据库保存session的方法简介
使用数据库保存session的方法 php的session默认是以文件方式保存在服务器端,并且在客户端使用cookie保存变量,这就会出现一个问题,当一个用户由于某种安全原因关闭了浏览器的cookie ...
- 使用无限生命期Session的方法
使用无限生命期Session的方法 [来源] 达内 [编辑] 达内 [时间]2013-03-28 Session储存在服务器端,根据客户端提供的SessionID来得到这个用户的文件,然后读 ...
- 清空session的方法
清空session的方法,常用来注销的时候清空所有的session. 方法一: Enumeration e=session.getAttributeNames(); while(e.hasMoreEl ...
- redis存储session配制方法
redis存储session配制方法需要三个模块: 1.redis 2.express-session 3.connect-redis 项目中的配置方法代码片段如下: 首先连接redis,连接redi ...
- Flask 框架中 上下文基础理念,包括cookie,session存储方法,requset属性,current_app模块和g模块
Flask中上下文,分为请求上下文和应用上下文.既状态留存 ,就是把变量存在某一个地方可以调用 请求上下文:实际就是request和session用法理念,既都是可以存储东西. 应用上下文:既变量共享 ...
- Hibernate(5)session的方法
1. Session缓存 Session缓存(Hibernate一级缓存),在 Session 接口的实现中包含一系列的 Java 集合, 这些 Java 集合构成了 Session 缓存.只要 Se ...
随机推荐
- python的re正则表达式模块
元字符 . * + ? ^ $ { } [ ] - \ . 匹配除了/n之外的任意一个字符 * 匹配*前面的单个字符任意次,即[0,+∞] + 匹配 ...
- DTMF在VOIP中的解决方案
双音多频DTMF(Dual Tone Multi-Frequency)信令,因其提供更高的拨号速率,迅速取代了传统转盘式电话机使用的拨号脉冲信令.DTMF也应用在交互式控制中,诸如语言菜单.语言邮件. ...
- VC++ 进度条更新方案
在实际开发中,如果有耗时操作,一般会在工作线程处理数据,然后处理完成后把时间传递到UI线程进行显示,切记不要在工作线程对UI进行操作. 场景: 1. 很多程序需要根据处理业务的进度来更新进度条,进度条 ...
- linux性能分析工具之火焰图
一.环境 1.1 jello@jello:~$ uname -a Linux jello 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03 UT ...
- Leading and Trailing(数论/n^k的前三位)题解
Leading and Trailing You are given two integers: n and k, your task is to find the most significant ...
- Mac OSX 安装qemu
参考: Installing QEMU on OS X Homebrew Mac OSX 安装qemu 1.Install Homebrew: /usr/bin/ruby -e "$(cur ...
- C# string[]转List<string>
List<string> ltProduct = new List<string>(Product.Split('|'));
- linux设置端口转发(一键设置)
linux设置端口转发 #下载rinetd程序并进入文件夹 wget http://www.boutell.com/rinetd/http/rinetd.tar.gz&&tar -xv ...
- flask报错No module named 'flask.ext'
解决: from flask.ext.httpauth import HTTPBasicAuth 改为 from flask_httpauth import HTTPBasicAuth 提示Modul ...
- python 多线程队列
##Using Queue with multiprocessing – Chapter : Process Based Parallelism import multiprocessing impo ...