How to save many objects in a spring <form:form>

前端 未结 1 1753
渐次进展
渐次进展 2020-12-06 13:57
@Component
@Entity
@Table(name=\"menu\")
@Configurable
public class Menu implements Serializable{      
    ....        
    @OneToMany(mappedBy=\"menu\", fetch=Fetc         


        
1条回答
  •  -上瘾入骨i
    2020-12-06 14:33

    The elements of a Set cannot be accessed by index. You will need to add methods which return a List wrapping your set.

    @Component
    @Entity
    @Table(name="menu")
    @Configurable
    public class Menu implements Serializable{      
        ....        
        @OneToMany(mappedBy="menu", fetch=FetchType.EAGER)
        private Set voceMenus; 
    
        public Set getVoceMenus() {
            return voceMenus;
        }
    
        public void setVoceMenus(Set voceMenus) {
            this.voceMenus = voceMenus;
        }
    
        //bind to this
        public List getVoceMenusAsList(){
            return new ArrayList(voceMenus);
        }
        .....   
    }
    

    JSP:

     
         Menu id
    ...... .....

    0 讨论(0)
提交回复
热议问题