Struts logic:iterate input field

后端 未结 4 2063
悲哀的现实
悲哀的现实 2021-01-03 07:37

I currently have the following code and the data is displayed fine.



        
4条回答
  •  一个人的身影
    2021-01-03 08:20

    Theoretically, the indexed attribute of the struts html tags could be used for this:

    Valid only inside of logic:iterate tag. If true then name of the html tag will be rendered as "id[34].propertyName". Number in brackets will be generated for every iteration and taken from ancestor logic:iterate tag.

    But, there is no corresponding indexed attribute on the html:errors tag, which limits its usefulness. Also, the required combination of id, name and property attributes can be rather confusing.

    I found it easier to use jsp scriptlets to generate the property name including the iteration index. The following code requires that your form has a string array property "quantity".

    <% int idx=0; %>
    
        
        
        <% i++; %>
    
    

提交回复
热议问题