public class LoginInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Map session=ActionContext.getContext().getSession();
if(session.get("naem")==null){
return "login";
}
return invocation.invoke();
}
}
在STRUTS.XML文件中配置的
<interceptors>
<interceptor name="loginInterceptor" class="com.Struts2.interceptor.LoginInterceptor"></interceptor>
</interceptors>
<global-results>
<result name="login">index.jsp</result>
</global-results>
下面的这个是放在你的Action当中的你需要拦截那个ACTION就放在那个Action下面
<result name="addPage" >prepareaction.jsp</result><result name="methodsPage">methodsPage.jsp </result>