jxtang1 2015-05-01 11:54
浏览 582

简单模拟struts中的Interceptor的调用过程遇到的问题

不明白struts中Interceptor的调用过程(Interceptors的遍历过程),自己写了个小程序测试。得不到想要的结果 求大神指点啊~~ 代码如下:

public class Interceptor {
Invocation test;
String name;
public Interceptor(String name){
this.name=name;
}

public String intercept(Invocation test) {
            this.test=test;
            System.out.println("--name--1--"+name);
            test.invoke();
            System.out.println("--name--2--"+name);
            eturn super.toString();
}

}

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Invocation {

public static void main(String[] args) {
        Invocation t = new Invocation();
        t.invoke();
}

    public void invoke(){
            List<Interceptor> list = new ArrayList<Interceptor>();
            list.add(new Interceptor("aaaaa"));
            list.add(new Interceptor("bbbbb"));
            list.add(new Interceptor("ccccc"));
            list.add(new Interceptor("ddddd"));
            list.add(new Interceptor("eeeee"));
            list.add(new Interceptor("fffff"));
            list.add(new Interceptor("ggggg"));
            list.add(new Interceptor("hhhhh"));
            Iterator<Interceptor>  iss =    list.iterator();
            if(iss.hasNext()){
                   Interceptor ms = iss.next(); 
                   ms.intercept(this);
           }

}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安装svn网络有问题怎么办
    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥15 latex怎么处理论文引理引用参考文献