Struts logic:iterate input field

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

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



        
4条回答
  •  温柔的废话
    2021-01-03 08:12

    So this is tricky, because there are many things to get done in order for it to work. First, declare your tags inside the iterator with the html tags, with attribute INDEXED=TRUE and an ID DIFFERENT THAN THE NAME, i also took out the "indexId" attribute to use the simple "index" word for the index:

      
      
            
            
            
      
    

    after that, in order for struts to be able to get and set the attributes of your beans, you need to declare EXTRA get and set methods inside your collection object, using the name you wrote in the id of the iterate tag. In this case, you would write 2 extra get and set methods for the "myListI" :

    public void setMyListI(int index, myBean value){
        this.myList.add(value);
    }
    public myBean getMyListI(int index){
        return this.myList.get(index);
    }
    

提交回复
热议问题