lzhc

 

继承AbstractInterceptor类,在类中完成拦截器的功能,只需实现intercept方法即可,提供了init()和destroy()的空实现

示例:显示执行action所用的时间

①在src中建包com.lzhc.interceptor,在包中建TimerInterceptor.java,使其继承AbstractInterceptor类

②在struts.xml中进行配置

在package内注册拦截器,代码如下:

<interceptors>

  <interceptor name="mytimer" class="com.lzhc.interceptor.TimerInterceptor"></interceptor>

</interceptors>

在需要用到拦截器的action中添加

<interceptor-ref name="mytimer"></interceptor-ref>

 

struts2的内建拦截器:

 

分类:

技术点:

相关文章:

  • 2021-09-14
  • 2021-08-19
  • 2021-09-26
  • 2022-01-03
  • 2022-01-05
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2021-09-14
  • 2021-04-07
  • 2022-01-02
  • 2022-01-20
  • 2022-12-23
  • 2021-09-14
相关资源
相似解决方案