request.getSession()和request.getSession(true)之间的区别 [英] Difference between request.getSession() and request.getSession(true)

查看:185
本文介绍了request.getSession()和request.getSession(true)之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解 request.getSession(true) request.getSession(false)之间的区别。但是 request.getSession()& request.getSession(true)看起来非常相似!

I understand the difference between request.getSession(true) and request.getSession(false). But request.getSession() & request.getSession(true) look very similar!

两者都返回与此请求相关的当前会话,但不同的是:

Both "return the current session associated with this request", but differ in:


或者如果请求没有会话,创建一个



request.getSession(true)



request.getSession(true):


如果有没有当前会话,返回新会话

我不明白它们之间的区别,是它(如果不存在)他们创建一个新的会话,但第一个不会返回它,但第二个会吗?

I don't understand the difference between them, is it that (if none exists) they create a new session but the first one doesn't return it but the second one does?

来源: http://docs.oracle.com/javaee/ 6 / api / javax / servlet / http / HttpServletRequest.html

编辑:

有人将我的问题标记/标记为重复,即使它不是。我将解释原因。

Someone tagged/marked my question as duplicate even though it isn't. I will explain why.

我已明确要求 request.getSession()& request.getSession(true)而不是 request.getSession(true)& request.getSession(假)!我再次明确地说过,我已经理解了差异b / w ..(true)& ..(false)

I have explicitly asked for the difference between request.getSession() & request.getSession(true) and NOT between request.getSession(true) & request.getSession(false)! I have stated , again explicitly, that I already understand the difference b/w ..(true) & ..(false).

问题链接作为可能重复的关于差异的问题b / w ..(true)& ..(false)而不是 ..(true)& ..()

The question linked as a possible duplicated of of asks about the difference b/w ..(true) & ..(false) and not ..(true) & ..()

推荐答案

请求。 getSession()只是一种方便的方法。它与 request.getSession(true)完全相同。

request.getSession() is just a convenience method. It does exactly the same as request.getSession(true).

这篇关于request.getSession()和request.getSession(true)之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆