//..... 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呢?到页面直接用个标签接可以了!何必这么麻烦??
//这个树组的长度自己想办法搞定吧,可以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呢?到页面直接用个标签接可以了!何必这么麻烦??
小弟的问题可能很弱智 但是真的想搞懂啊 大哥帮帮忙啊
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();
//实际上接口定义的是他的实现类.只是因为他们都实现了同一接口.
//不是你的问题弱智.没人弱智
//是你太少看书了
servlet操作业务,将bean放入request,然后转发jsp,在jsp中显示。范例
http://family168.com/tutorial/jsp/html/jsp-ch-06.html#jsp-ch-06-03
现在有程序:
ArrayList rules = associateRules.getAssociateRules();
Iterator rulesIterator = rules.iterator();
while(rulesIterator.hasNext())
{
String str = (String)rulesIterator.next();
out.println(str);
}
其中 Iterator rulesIterator = rules.iterator();语句,它返回的是Iterator接口,它返回的它的实现类吗?
如果是的话,它的实现类是什么啊?
你可以看下ArrauList这个类,他继承了AbstractList这个抽象类
AbstractList.iterator方法
返回一个 Itrpublic Iterator<E> iterator() {
return new Itr();
}而Itr实现了java.util.Iterator接口,so...这底层的东西我也没怎么研究过.你自己看下API或者看看JDK的书.