Struts2_Interceptor(拦截器)

来源:互联网 发布:大学生找兼职软件 编辑:程序博客网 时间:2024/06/05 15:58

自定义拦截器:

1、编写拦截器的类继承接口Interceptor;

2、struts.xml配置如下:

<package name="test" namespace="/" extends="struts-default">  <interceptors>   <interceptor name="my" class="com.jimmy.action.MyInterceptor"></interceptor>  </interceptors>        <action name="test" class="com.jimmy.action.TestAction">            <result>/test.jsp</result>            <interceptor-ref name="my"></interceptor-ref>            <interceptor-ref name="defaultStack"></interceptor-ref>        </action> </package>

Struts2默认的拦截器不能覆盖,因此红色部分得写。

原创粉丝点击