In fact, there are a lot of methods, I caught dead this.
Use the four scopes to understand Java.
Idea: The key to understanding the four main scopes of Java.
First place to land:
1. The requested SessionID and login username
2. Save the SessionID in the application, the user name is stored in the current session
Actioncontext ac = actioncontext.getcontext (); Map<string, object> applicationmap=ac.getapplication (); Map<string, object> sesisonmap = ac.getsession ();
The requested SessionID String Currentseesionid= getrequest (). GetSession (). GetId (); Applicationmap.put (Loanusere.getuname (), Currentseesionid); Sesisonmap.put (Commonvar.sso_login_name_key,loanusere.getuname ());
Second place to land:
1. Get the browser's SessionId and get the login username
2. In the current session to obtain the user name corresponding keyword, with the keyword in the application to get SessionID,
For comparison, not equal to jump to landing.
Interceptors:
/**initialization parameters are obtained*/Actioncontext Actioncontext=Arg0.getinvocationcontext (); /**httpservletrequest Parameters*/HttpServletRequest Request=(HttpServletRequest) actioncontext.get (strutsstatics.http_request); /**httpservletresponse Parameters*/HttpServletResponse Response=(HttpServletResponse) actioncontext.get (strutsstatics.http_response); /**Session Parameters*/Map<string, object> sessionmap =actioncontext.getsession (); Map<string, object> appcationmap =actioncontext.getapplication (); String LoginName=NULL; //SessionID in the context objectString sessionId =NULL; if(!Sessionmap.isempty ()) {LoginName=(String) sessionmap.get (Commonvar.sso_login_name_key); } if(NULL!=loginName) {SessionId=(String) appcationmap.get (loginName); } //SessionID of the current sessionString Currentsessionid =request.getsession (). GetId (); if(!currentsessionid.equals (sessionId)) { return"Loanuserlogin"; }
Java implementation of an account can only be landed in one place, other places are offline