Chinaunix首页 | 论坛 | 博客
  • 博客访问: 739650
  • 博文数量: 771
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-11 14:24
文章分类

全部博文(771)

文章存档

2011年(1)

2008年(770)

我的朋友

分类:

2008-09-11 14:33:57

struts拦截器使用

一 方法调用之后使用的拦截器 实现interceptor 接口

拦截器 一定是线程的,就是要同步

public interface Interceptor extends Serializable
{
     void destroy();
     void init();
     String intercept(ActionInvocation invocation) throws Exception;
}

实现方法intercept

example

import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; public class SimpleInterceptor extends AbstractInterceptor
{
     public String intercept(ActionInvocation invocation) throws Exception
{
        MyAction action = (MyAction)invocation.getAction(); 
       action.setDate(new Date()); 
       return invocation.invoke(); 
    }
}

 


    ...   
      
         
         
          ...      

   

    ...


二  要实现在之前 调用 就实现 PreResultListener的接口

【责编:landy】

--------------------next---------------------

阅读(381) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~