- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
request.getSession().getId()
和 request.getRequestedSessionId()
有什么区别?它们是否都返回相同的东西,即 session ID?
谢谢
最佳答案
request.getRequestedSessionId()
将返回客户端指定的 session ID(大概在 cookie 中)。 request.getSession().getId()
将返回服务器的 session ID(如果 session 不存在,request.getSession()
将创建它)。
重要的区别是您不能依赖 request.getRequestedSessionId()
返回的值,因为它可能无效。来自文档:
Returns the session ID specified by the client. This may not be the same as the ID of the current valid session for this request. If the client did not specify a session ID, this method returns null.
关于java - request.getSession().getId() 与 request.getRequestedSessionId(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38797066/
request.getSession().getId() 和 request.getRequestedSessionId() 有什么区别?它们是否都返回相同的东西,即 session ID? 谢谢 最
我是一名优秀的程序员,十分优秀!