怎样用Struts的<logic:iterator/>标签遍历ArrayList里面的对象 <logic:iterator name="result" id="rs"> <bean:writer name="rs" property=""/></logic:iterator>property放你在result中的属性名 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那你就在action 里做两手准备,当是BeanA时 就request.setAttribute("A", result);当是BeanB 就request.setAttribute("B", result);然后在jsp页面上...... <logic:notEmpty name="A"> <br><bean:write name="A" property="(A的某个属性)"/> <br><bean:write name="A" property="(A的某个属性)"/> </logic:notEmpty> <logic:notEmpty name="B"> <br><bean:write name="B" property="(B的某个属性)"/> <br><bean:write name="B" property="(B的某个属性)"/> </logic:notEmpty>......这样不就行了吗,BeanA 、BeanB肯定会显示出来一个! 谢谢楼上的这位大哥,问题是我在action里面返回的result是一个ArrayList对象,而不是BeanA或BeanB的数组,那我该怎么判断result里面存的到底是BeanA还是BeanB呢? <logic:iterate name="studentList" id="studentList"> <bean:write name="studentList" property="studentid"></bean:write> <bean:write name="studentList" property="studentname"></bean:write></logic:iterate>studentList就是你传过来的LISTproperty是你LIST里面存的对象的属性 你把list里面的取出来判断一下类型不就行了,Object o=list.get(0);if(Object instanceof A){ request.setAttribute("a",list);}else if(Object instanceof B){ request.setAttribute("b",list);}不过哪有人连自己在list里存的是什么都不知道的,jdk1.5还加了泛型,给你用不是浪费 Ibatis查询为空 求Spring高手,别犹豫了,进来吧。 请教个关于JAVA包的问题 JSP页面显示空白 我在websphere部署带ejb的ear包出现下列问题,盼GGJJ帮忙 求有关Web Service的英文材料 求助 到底应该怎么执行hibernate的max等聚合函数 java读取word模版,向模版中写入数据,生成一个新的word jsp显示 eXtremeTable什么和struts的logic标签结合? JSP中如何获取客户端上次请求的信息
然后在jsp页面上
......
<logic:notEmpty name="A">
<br><bean:write name="A" property="(A的某个属性)"/>
<br><bean:write name="A" property="(A的某个属性)"/>
</logic:notEmpty>
<logic:notEmpty name="B">
<br><bean:write name="B" property="(B的某个属性)"/>
<br><bean:write name="B" property="(B的某个属性)"/>
</logic:notEmpty>
......
这样不就行了吗,BeanA 、BeanB肯定会显示出来一个!
<bean:write name="studentList" property="studentid"></bean:write>
<bean:write name="studentList" property="studentname"></bean:write>
</logic:iterate>studentList就是你传过来的LIST
property是你LIST里面存的对象的属性
Object o=list.get(0);
if(Object instanceof A){
request.setAttribute("a",list);
}else if(Object instanceof B){
request.setAttribute("b",list);
}
不过哪有人连自己在list里存的是什么都不知道的,jdk1.5还加了泛型,给你用不是浪费