import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class LoginInterceptor extends AbstractInterceptor {
public String intercept (ActionInvocation invocation) throws Exception {
String statte = (String) ServletActionContext.getRequest().getSession().getAttribute ("login_state"); //获取登陆状态
if (statte != null) { //判断是否为空
return invocation.invoke(); //如果为是,继续执行ACTION方法
} else {
return "backerror"; //如果为否,弹出
}
}
}
error.jsp
login.jsp