Spring MVC无法接收字符串集

时间:2018-07-25 18:38:08

标签: spring spring-boot thymeleaf

休眠

我有一个实体:工厂

detailsOfPans.forEach(map -> map.forEach((k, v) -> {
    // Do something with k, v
}));

在百里香叶中向工厂添加电子邮件,

@Entity
public class Factories extends BaseEntity {

    @Id
    @SequenceGenerator(name = "factories_id_seq", sequenceName = "factories_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "factories_id_seq")
    private Integer id;


    @ElementCollection
    private Set<String> emails = new HashSet<String>();

    //get set...
}

当我尝试保存时,我得到了

  

org.springframework.beans.InvalidPropertyException:无效的属性   Bean类[com.lcm.model.Factories]的“ emails [0]”:属性   索引属性路径“ emails [0]”中引用的数组都不是   既不是列表也不是地图;返回值是[[]]

1 个答案:

答案 0 :(得分:1)

这是不可能的,因为设置没有顺序...请检查此帖子,还有其他选择...

Need help with binding Set with Spring MVC form