public class LoginInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionProxy proxy = invocation.getProxy();
String methodName = proxy.getMethod();
String actionName = proxy.getActionName();
if ("login".equals(actionName)) {
return invocation.invoke();
}
if (!(isLogin())) {
ActionContext actionContext = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest) actionContext
.get(StrutsStatics.HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse) actionContext
.get(StrutsStatics.HTTP_RESPONSE);
response.sendRedirect(request.getContextPath()
+ "/loginmgmt/login!login.action");
return null;
}
return invocation.invoke();
}
}