日期:2014-05-18 浏览次数:20741 次
public class AuthorizationInterceptor extends AbstractInterceptor {
public String intercept(ActionInvocation arg0) throws Exception {
System.out.println("arg0:"+arg0.getAction().getClass().getName());
Map<?, ?> session = arg0.getInvocationContext().getSession();
Object obj=session.get(StaticConfig.SESSIONUSERINFO);
if(obj==null){
System.out.println("拦截器:用户未登录---");
return "index";
}else{
return arg0.invoke();
}
}
}
<package name="sbase" namespace="/" extends="struts-default">
<interceptors>
<!-- <interceptor name="configdebug" class="com.configdebug.interceptor.ConfigDebugInterceptor"/> -->
<interceptor name="authority" class="com.kjs.base.AuthorizationInterceptor"/>
<interceptor name="defaultin" class="com.kjs.base.DefaultInterceptor"/>
<interceptor-stack name="user" >
<!-- <interceptor-ref name="configdebug" /> -->
<interceptor-ref name="defaultin" />
<interceptor-ref name="authority" />
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
<interceptor-stack name="guest" >
<!-- <interceptor-ref name="configdebug" /> -->
<interceptor-ref name="defaultin" />
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="guest"/>
<global-results>
<result name="index" type="redirectAction">index</result>
<result name="error" type="redirectAction">/error.jsp</result>
</global-results>