How to insert a value into Set collection in Struts 2

那年仲夏 提交于 2019-11-27 14:33:24

Set is a Collection and as any other collection could be indexed by a property.

@Element(value = Student.class)
@Key(value = Integer.class)
@KeyProperty(value = "id") 
@CreateIfNull(value = true)
private Set<Student> students = new HashSet(0);
//getter and setter, also for Student class that should have Integer id.

in JSP

<s:iterator value="students " var="student">
  <s:textfield name="students(%{#student.id}).name" />
</s:iterator>

More about this see in Indexing a collection by a property of that collection.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!