Java implements an account that can only log on to the same region, go offline elsewhere, and go offline in java
In fact, there are a lot of methods, and I am ugly.
Use to understand the four major scopes of java.
Idea: understand the key to the Four Scopes of java.
First place login:
1. Get the SessionId and username of the request.
2. Save the SessionId to the application and the user name to the current session.
ActionContext ac = ActionContext. getContext (); Map <String, Object> applicationMap = ac. getApplication (); Map <String, Object> sesisonMap = ac. getSession ();
// The sessionId String currentSeesionId = getRequest (). getSession (). getId (); applicationMap. put (loanUserE. getUname (), currentSeesionId); sesisonMap. put (CommonVar. SSO_LOGIN_NAME_KEY, loanUserE. getUname ());
Second place login:
1. Get the SessionId of the browser and the username for login
2. Get the keyword corresponding to the user name in the current session, and use the keyword to get the SessionId in the application,
For comparison, jump to login if they are not equal.
Interceptor:
/** Get the initialization parameter */ActionContext actionContext = arg0.getInvocationContext ();/** HttpServletRequest parameter */HttpServletRequest request = (HttpServletRequest) actionContext. get (StrutsStatics. HTTP_REQUEST);/** HttpServletResponse parameter */HttpServletResponse response = (HttpServletResponse) actionContext. get (StrutsStatics. HTTP_RESPONSE);/** Session parameter */Map <String, Object> sessionMap = actionContext. getSessi On (); Map <String, Object> appcationMap = actionContext. getApplication (); String loginName = null; // sessionId String sessionId = null in the context Object; if (! SessionMap. isEmpty () {loginName = (String) sessionMap. get (CommonVar. SSO_LOGIN_NAME_KEY);} if (null! = LoginName) {sessionId = (String) appcationMap. get (loginName);} // sessionId of the current session String currentSessionId = request. getSession (). getId (); if (! CurrentSessionId. equals (sessionId) {return "loanUserLogin ";}