Struts 2 アプリケーションで問題が発生しています。ユーザー 1 は正常にログインし、いくつかのページにリダイレクトされます。その後、ユーザー 2 が自分のマシンからログインしようとすると、ユーザー 1 のランディング ページにリダイレクトされます。
それが Web コンテナー (Web ロジック) の問題なのか、コーディングの問題なのかわかりません。どこで問題が発生するのか、サーバーが別のユーザー セッションからデータを提供する方法がわかりません。
ログイン アクションはセッション対応を実装します。セッション マップにはセッターとゲッターがあります。ログイン アクションが成功を返した場合、ユーザーは別のアクションにリダイレクトされ、そのアクションは再びセッション対応を実装します。
問題は本当に奇妙です。誰もがそれが起こっている理由を提案できますか.
また、複雑さを増すために、同じアプリケーション ear がローカルで正常に動作します。この問題は、テスト サーバーにデプロイしようとしたときにのみ発生します。
これがintercepotrコードです。スレッドセーフではないと思います。
public class UserAuthentication extends AbstractInterceptor
{
public UserAuthentication()
{
}
public void init(){//System.out.println("init'd");
}
public void destroy() {System.out.println("destroyed");}
public String intercept(ActionInvocation invocation) throws Exception
{
String className = invocation.getAction().toString();
Map OHRMS = ActionContext.getContext().getSession();
System.out.println("EmpInfoUpd: " + new Date() + " Inside the interceptor: ");
System.out.println("EmpInfoUpd: " + new Date() + " Interceptor called for action: " + className);
System.out.println("EmpInfoUpd: " + new Date() + " Now printing the entries of session map from interceptor: " + OHRMS);
Employee temp = (Employee)OHRMS.get("emp");
if(temp==null)
{ System.out.println("EmpInfoUpd: " + new Date() + " The session had no \"emp\" object. Interceptor returned \"login\" ");
return "login";
}
System.out.println("EmpInfoUpd: " + new Date() + " The session had \"emp\" object with Employee name: " + temp.getFullName()+ " Interceptor returned \"login\" ");
return invocation.invoke();
}
}