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在執行以前都進過這些攔截器