您当前的位置: 首页 > 

宝哥大数据

暂无认证

  • 0浏览

    0关注

    1029博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Stutus2拦截器(2)

宝哥大数据 发布时间:2016-07-31 16:37:56 ,浏览量:0

Stutus2拦截器(2)–自定义拦截器

第一步:实现AbstratIntercepter, 重写intercept() 第二步: 在strtus.xml中注册Interceptor

第一步:实现AbstratIntercepter, 重写intercept()

public class TimerInterceptor extends AbstractInterceptor {

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        // 1.执行Action之前
        long start = System.currentTimeMillis();
        // 2.执行下一个拦截器,如果已经是最后一个拦截器,则执行目标Action
        String result = invocation.invoke();
        // 3.执行Action之后
        long end = System.currentTimeMillis();
        System.out.println("执行Action花费的时间:" + (end - start) + "ms");

        return result;
    }

}

第二步: 在strtus.xml中注册Interceptor





    
    

    
        
        
            
        

        
            /success.jsp
            
            
            
            
        
    

关注
打赏
1587549273
查看更多评论
立即登录/注册

微信扫码登录

0.0462s