Struts2配置文件的详解

1.struts2的拦截器:继承

拦截器分为自定义拦截器和struts2默认的拦截器io

自定义拦截器的action:class

1.继承 AbstractInterceptorstruts2

2.重写 intercept方法配置

3.在intercept方法中进行拦截操做引用

struts2默认的拦截器,直接引用方法

struts2的配置文件中如何引入拦截器配置文件

1.注册拦截器tools

<interceptors>struts

            <!-- 单个拦截器-->
            <interceptor name="myExceptionInterceptor"
                class="com.hq.tools.MyExceptionInterceptor">
            </interceptor>
            <!-- 拦截器栈 -->
            <interceptor-stack name="myStack">
                <interceptor-ref name="myExceptionInterceptor"></interceptor-ref>

                <!--引入默认的拦截器栈-->
                <interceptor-ref name="defaultStack"></interceptor-ref>
            </interceptor-stack>

</interceptors>

2.使用拦截器

<default-interceptor-ref name="myStack"></default-interceptor-ref>

3.该包下面的action在执行以前都进过这些拦截器