你的意思是不是FormBean中有两个成员是数组,要把这两个数组按照一定的排列方式显示出来?

解决方案 »

  1.   

    假设VestForme 有两个数组属性start和end.
    <%
    com.guoan.cps.form.VestForm vestForm = new com.guoan.cps.form.VestForm();
    String[] aa = {"a1","a2","a3"};
    String[] bb = {"b1","b2","b3"};
    vestForm.setStart(aa);
    vestForm.setEnd(bb);
    request.setAttribute("vestForm",vestForm);
    %>
    <logic:iterate name="vestForm" id="vest" property="start" indexId="index">
    <bean:write name="vestForm" property='<%="start["+index+"]"%>'/>
    <bean:write name="vestForm" property='<%="end["+index+"]"%>'/>
    <br>
    </logic:iterate>
    输入效果为:
    a1 b1 
    a2 b2 
    a3 b3 
      

  2.   

    方法1:主要是先在Action中或ActionForm中处理好,生成满足输出格式的数据形式:先用数组name1[0]、name1[1],再用ArrayList。或者用二维数给name1[i][0]、name1[i][1]或者合并name1,name2成一行数据,再用ArrayList。方法2:采用嵌套循环,用<logic:iterate>的indexID属性和<logic:equal>(或者直接写<% if %>)实现。
      

  3.   

    方法1:主要是先在Action中或ActionForm中处理好,生成满足输出格式的数据形式:先用数组name1[0]、name1[1],再用ArrayList。或者用二维数给name1[i][0]、name1[i][1]或者合并name1,name2成一行数据,再用ArrayList。方法2:采用嵌套循环,用<logic:iterate>的indexID属性和<logic:equal>(或者直接写<% if %>)实现。
      

  4.   

    to: xunyiren(从jsp开始)
    你的方法我试了,能行,谢谢,但我有点忧虑这样做有点不符合struts的要求.to: kui(kui) 
    你说的方法2能不能给个详细的说明,谢谢了。
      

  5.   

    这怎么不符合Struts要求,我在<%--%>之间写的代码你应该把它放到Action的execute方法中,这么写我是想让你看的更明白一些...晕
      

  6.   

    这是Jakarta官方网站上对Indexed Properties部分说明:The JSP specification discusses using "indexed properties" in reference to the <jsp:setProperty> tag. However, none of the support provided in the base JSP specification actually deals with the "indexing" part. In truth, it allows for setting "array properties", but it doesn't do much for setting or even getting the actual values in each entry of the array, except with explicit JSP expressions (<%= %>).
      

  7.   

    to: xunyiren(从jsp开始)
    不好意思,我可能没说清楚,我的意思是property='<%="start["+index+"]"%>'里面嵌入了<% %>这些符号,是不是不好。
      

  8.   

    是的,尽量不要在页面中写任何<% %>的东西,以后会很麻烦。实在没有合适的tag,宁愿自己做一个也好。
      

  9.   

    In truth, it allows for setting "array properties", but it doesn't do much for setting or even getting the actual values in each entry of the array, except with explicit JSP expressions (<%= %>).Jakarta官方网站上对Indexed Properties在取beann属性的数组元素是认为只能这么取...