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