Session 当仅http设置为true时,httpservletrequest为null

Session 当仅http设置为true时,httpservletrequest为null,session,jboss7.x,httponly,Session,Jboss7.x,Httponly,我正在使用JBoss 7,我在web.xml中配置了会话配置,如下所示: <session-config> <session-timeout>240</session-timeout> <http-only>true</http-only> </session-config> request.getSession(false); 我遗漏了什么吗?这似乎是正确的 片段: Returns the current HttpSe

我正在使用JBoss 7,我在web.xml中配置了会话配置,如下所示:

<session-config>
<session-timeout>240</session-timeout>
<http-only>true</http-only>
</session-config>
request.getSession(false);

我遗漏了什么吗?

这似乎是正确的

片段:

Returns the current HttpSession associated with this request or, 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.
再次查看您的
web.xml
代码片段后,发现它不太正确。
不是
的一部分。按照以下步骤将其移动到


240
真的

谢谢,詹姆斯。如果web.xml中没有true,则可以检索有效会话。为真时为什么没有会话?我在jsp文件中设置会话属性,如下所示“session.setAttribute(“fileName”,fileName)”。我还在httpservletrequest对象中将此属性设置为“request.setAttribute(“fileName”,fileName)”。然而,在我的java代码中,当我执行“request.getSession(false)”时,会得到一个空会话。当我执行“request.getAttribute”(“fileName”)时,我仍然会得到null。这是我在web.xml中设置为true时看到的行为。当我从web.xml中删除时效果很好。我是否遗漏了任何内容?感谢您的帮助