首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

request.getSession()、request.getSession(false)跟request.getSession(true)的区别

2012-12-19 
request.getSession()、request.getSession(false)和request.getSession(true)的区别request.getSession()、

request.getSession()、request.getSession(false)和request.getSession(true)的区别

request.getSession()、request.getSession(false)和request.getSession(true)的区别:

在J2EE的API文档中关于HttpSession getSession(boolean create)的说明是:
Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.
而对于HttpSession getSession()的说明是:
Returns the current session associated with this request, or if the request does not have a session, creates one.

由此可见:request.getSession()和request.getSession(true)是等价的。

热点排行