使用struts2拦截器必须实现 com.opensymphony.xwork2.interceptor.Interceptor
public class PremissionInterceptor implements Interceptor{
public void destroy() {
}
public void init() {
}
public String intercept(ActionInvocation arg0) throws Exception {
return null;
}
}
struts配置:
<interceptors>
<interceptor name="premission" class="com.sdyt.web.PremissionInterceptor"></interceptor>
<interceptor-stack name="premissionStack">
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="premission"></interceptor-ref>
</interceptor-stack>
</interceptors>
<action name="login">
<interceptor-ref name="premissionStack"></interceptor-ref>
<result>/WEB-INF/login.jsp</result>
</action>
由于struts文件上传中都使用了默认拦截器栈:defaultStack,所以自定义拦截器栈必须先引用 defaultStack。
定义默认拦截器:
<default-interceptor-ref name="premissionStack"></default-interceptor-ref>
但某包中已经使用了自定义拦截器,默认拦截器将不会起作用,所以注意把默认拦截器带上。