【发布时间】:2012-05-24 04:40:30
【问题描述】:
我正在使用 Struts2。我的 pojo 中有一个哈希集。我正在尝试将值提交到哈希集。我无法将我的收藏类型更改为列表。
这里是波乔
Item{
Set<Person> personCollection;
long itemCode;
public void setItemCode(long itemCode)
{
this.itemCode=itemCode;
}
public long getitemCode()
{
return itemCode;
}
public void setPersonCollection(Set<Person>personCollection)
{
this.personCollection=personCollection;
}
public Set<Person> getPersonCollection()
{
return personCollection;
}
}
Person{
String name;
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
}
动作
SubmitItemAction
{
private Item item;
public getItem()
{
return item;
}
public setItem(Item item)
{
this.item=item;
}
public String submitItem()
{
dao.submit(item);
}
}
jsp
<s:text name=item.personCollection[0].name/>
<s:text name=item.personCollection[1].name/>
所以这不起作用。当我使用上面的 sn-p 提交我的 jsp 时,它给出了错误,它无法从 Item 中填充 personCollection。
那么jsp中的命名约定应该是什么?就像如果 personCollection 是我可以使用 item.personCollection[0].someProperty 的列表一样。但是你如何设置类型集的集合的名称。
【问题讨论】:
-
你必须在 JSP 中这样做吗?为什么不行动?
-
简而言之-问题是如何在jsp中直接使用HashSet来提交一组值?