How do you iterate through a list of objects?

后端 未结 5 810
南笙
南笙 2021-01-04 11:23

I have a User class that has a String username in it. I have a list of users that I\'m trying to display in a table using

                         

        
5条回答
  •  轮回少年
    2021-01-04 11:54

    First, in Struts2 2.1.x the id attribute is deprecated, var should be used instead (ref)

    I think the # is misused there. Besides, "list" seems a bad name for what is to be assigned in each iteration... I think "user" is more appropiate.

    IIRC, the syntax is

     
      ...  
     
    

    Further, you don't need to assign the current item in the iterator for such a simple case. THis should also work:

     
      ...  
     
    

    Also you might want to try this:

      
          ...        
      
    

    UPDATE: I corrected the bit about the #, it was ok.

提交回复
热议问题