<logic:iterator name="result" id="rs">
 <bean:writer name="rs" property=""/>
</logic:iterator>property放你在result中的属性名

解决方案 »

  1.   

    那你就在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肯定会显示出来一个!
      

  2.   

    谢谢楼上的这位大哥,问题是我在action里面返回的result是一个ArrayList对象,而不是BeanA或BeanB的数组,那我该怎么判断result里面存的到底是BeanA还是BeanB呢?
      

  3.   

    <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就是你传过来的LIST
    property是你LIST里面存的对象的属性
      

  4.   

    你把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还加了泛型,给你用不是浪费