//..... List 省略
//这个树组的长度自己想办法搞定吧,可以list.size()*bean属性个数
//下面是不算解决方案的解决方案
Iterator it=list.iterator();
String[] arr = new String[8];
int count=0;
TagBean tag;
while(it.hasNext()){
tag = (TagBean) it.next();
arr[count]=tag.getAaaa();
count++;
arr[count]=tag.getBbbb();
count++;
arr[count]=tag.getCccc();
count++;
arr[count]=tag.getDddd();
count++;
}
request.setAttribute("arr", arr);
//JSP
<%
String[] arr=(String[])request.getAttribute("arr");
for(int i=0;i<arr.length;i++){
out.print(arr[i]+"<br>");
}
%>//实在想不出来你为啥有这么变态的需求.
//为啥不用LIST或者VECTOR呢?到页面直接用个标签接可以了!何必这么麻烦??

解决方案 »

  1.   

    谢谢啊 我已经能够实现了啊 不过就是要JSP页面中加入JAVA语句啊 
      

  2.   

    本人JAVA是初学 我想问一下大哥 Iterator和List 不是都是接口吗 怎么能够定义变量啊 
    小弟的问题可能很弱智 但是真的想搞懂啊 大哥帮帮忙啊
      

  3.   


    interface IA(){
      void helloWorld();
    }class Aimpl() implement IA{
      void helloWorld(){
        System.out.print("hello world!");
      }
    }class Bimpl() implment IA{
      void helloWorld(){
        System.out.print("hello world!");
      }
    }IA a=(Aimpl)new XXX();
    a.helloWorld();
    IA b=(Bimpl)new XXX();
    b.helloWorld();
    //实际上接口定义的是他的实现类.只是因为他们都实现了同一接口.
    //不是你的问题弱智.没人弱智
    //是你太少看书了
      

  4.   

    用servlet就好了
    servlet操作业务,将bean放入request,然后转发jsp,在jsp中显示。范例
    http://family168.com/tutorial/jsp/html/jsp-ch-06.html#jsp-ch-06-03
      

  5.   

    我还想问一下关于Iterator:
    现在有程序:
      ArrayList rules = associateRules.getAssociateRules();
      Iterator rulesIterator = rules.iterator();
      while(rulesIterator.hasNext())
     {
      String str = (String)rulesIterator.next();
      out.println(str);
     }
    其中 Iterator rulesIterator = rules.iterator();语句,它返回的是Iterator接口,它返回的它的实现类吗?
    如果是的话,它的实现类是什么啊?
      

  6.   

    你的ArrayList rules 是ArrayList的实例
    你可以看下ArrauList这个类,他继承了AbstractList这个抽象类
    AbstractList.iterator方法 
    返回一个 Itrpublic Iterator<E> iterator() {
      return new Itr();
    }而Itr实现了java.util.Iterator接口,so...这底层的东西我也没怎么研究过.你自己看下API或者看看JDK的书.