Chinaunix首页 | 论坛 | 博客
  • 博客访问: 264917
  • 博文数量: 757
  • 博客积分: 40040
  • 博客等级: 大将
  • 技术积分: 4935
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-09 12:37
文章分类

全部博文(757)

文章存档

2011年(1)

2008年(756)

我的朋友

分类:

2008-09-09 12:44:01

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---------------------

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