0
我有一个Singleton对象,它保存了基于“Spring”的仪表板所需的所有数据。我将这个单例对象存储在我登录时从控制器接收到的httpservlet请求中。如何防止session.attribute在eclipse重新加载apache时变为null
servlet.getSession().setAttribute(SESSION_DATA, sessionData);
一旦我已经登录我检查,看看是否sessionData已成为空,并尝试从servlet.session.attribute
检索。但是从servlet.session.attribute
所有属性成为空
- 每隔几分钟我的Apache(通过日食)当我保存源文件
的
session.attribute
成为空值 ? if (sessionData == null)
if (httpServlet != null && httpServlet.getSession() != null
&& httpServlet.getSession().getAttribute(SESSION_DATA) != null) {
log.info("Recovering sessionData from http session");
sessionData = (SessionDataManager) httpServlet.getSession().getAttribute(SESSION_DATA);
} else {
log.warn((httpServlet == null) ? "httpServlet is null" : "httpServlet is not null");
if (httpServlet != null) {
log.warn((httpServlet.getSession() == null) ? "httpServlet.getSession is null"
: "httpServlet.getSession is not null");
if (httpServlet.getSession() != null)
log.warn((httpServlet.getSession().getAttribute(SESSION_DATA) == null)
? "httpServlet.getSession.getAttribute(SESSION_DATA) is null"
: "httpServlet.getSession.getAttribute(SESSION_DATA) is not null");
}
}
我们不能使用会话范围的spring bean,而不是设置session属性。 – ArslanAnjum
请你详细说明一下吗?或者给我一个我可以使用的链接。 – Siddharth