“比如在另一个地方改为list2,因为其余都相同”,改法有两种,一种是引用,会影响,但如果用得好,也可,一种是重新实例以list2保存,这一定可以。

解决方案 »

  1.   

    1.<bean:define id="list2" name="list1"/> ,下面用“list1”与“list2”结果是一样的,这时是引用。property1的值为1或2是两类信息。
    <logic:iterate id="rec" name="list1">
      <logic:equal name="rec" property="property1" value="1">
        <bean:write name="rec" property="content"/>
      </logic:equal/>
    </logic:iterate><logic:iterate id="rec" name="list2">
      <logic:equal name="rec" property="property1" value="1">
        <bean:write name="rec" property="content"/>
      </logic:equal/>
    </logic:iterate>
    2.<%
      ArrayList list1=(ArrayList)pageContext.getAttirbute("list1",3);
      ArrayList list2=getArrayListByYouMethod(list1);
        //如果list1!=list2 ,就是说二是两个实例,但内容相同。
      //写两个循环语句,将list1中bean属性property1值为2的删除。将list2中bean属性
    property1值为1的删除。
      pageContext.setAttribute("list2",list2);
    %>
    这是建一新实例。jsp页面上用struts的<logic:iterate />标签就不用判断property1的值是1还是2了。
    <logic:iterate id="rec" name="list1">
        <bean:write name="rec" property="content"/>
    </logic:iterate><logic:iterate id="rec" name="list2">
        <bean:write name="rec" property="content"/>
    </logic:iterate>
      

  2.   

    那只能动态写table之类的东西了。property1如果是1,在id为"tb1"的table中插入一行,否则在id为"td2"的table中插入一行。