jstl/jsp - iterating over a vector of beans

后端 未结 2 870
迷失自我
迷失自我 2021-01-27 19:21

I have a vector of beans that holds information I want to display in my jsp page. I\'m currently just using standard java expressions to display this, I want to look into using

2条回答
  •  后悔当初
    2021-01-27 20:04

    I think that what you are looking for is the < c:foreach > tag.

    for example, printing the value myInt property on instances of MyClass (defined below):

    
           
           
    
           
           
     
    

    where vector name is the name of the vector ,for example, after doing a

    Suppose you have a class myClass.

    public class MyClass{
       private MyClass relatedInstance;     
       //some members and methods
    
       public int getMyInt(){
         //return something
       }
    
       public MyClass getRelatedInstance(){
         return this.relatedInstance;
    }
    
    List my_vector = getFilledList();
    request.setAttribute("vectors name",my_vector)
    

提交回复
热议问题