我在處理會話中的對象時遇到問題。在Struts應用程序中處理會話
我存儲的對象而在這樣的會議。假設對象是對象的名稱。我做這在我的動作類:
if(object!=null)
{
session.settAttribute("objectName",object);
return mapping.findForward("success");
}
else
{
return mapping.findForward("failure");
}
我映射成功和失敗的相同的JSP頁面。我檢查就像
if(session.getAttribute("objectName")!=null)
{
object= (SomeObjectClass)session.getAttribute("objectName");
}
if(object!=null)
{
//Do this
}
else
{
//Do that
}
現在來了我的問題。在會話中第一次設置對象時沒有問題。當我從兩個不同的瀏覽器同時調用這個操作類時,我遇到了一個問題,同時我去其他部分處理一個案例,如果部分處理一個案例。我相信這是因爲會話不是線程安全的。有沒有解決方法?
在動作類檢索 - 絕對正確的,但不是在所有樂於助人:-) – ChssPly76 2009-10-15 06:09:04
我會糾正自己在一分鐘內:) – cetnar 2009-10-15 06:10:57
我發現什麼是problem.its因爲我已經宣佈 的HttpSession之外,這使得全球會議每一個線程調用,因此疑難問題的excecute方法已糾正它。 – Harish 2009-10-15 07:47:42