我试图用弹簧的选择标记选择多个选项来填充列表。 我选择的标签很好地显示,当我选择的选项列表中正确更新。
我唯一的问题是,当我渲染为与已填补表,我选择标签并不突出所选的选项。 我已经尝试调试和伊灿看到该列表不是空的,这是真的,这似乎为选择不标记选择的选项标签。
我的代码:
@Entity
public class ProductsGroup
{
@Version @Column(name = "version")
private Integer version;
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id")
private Integer id;
@ManyToMany(fetch = FetchType.EAGER)
private List<Product> products;
public List<Product> getProducts()
{
return products;
}
public void setProducts(List<Product> products)
{
this.products = products;
}
}
@Entity
public class Product
{
@Version @Column(name = "version")
private Integer version;
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id")
private Long id;
private String name;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
<form:form action="${action}" class="fancyform" commandName="productsGroup" id="productForm">
....
<form:select path="products" items="${products}" itemLabel="name" itemValue="id" multiple="true"/>
....
</form:form>