【发布时间】:2011-11-08 21:51:01
【问题描述】:
我正在使用 Spring form 标记库在我的 JSP 中进行表单绑定。我的命令对象包含一个 Set,我想使用 JSTL <c:forEach> 迭代该集合,并为我的集合中的每个对象创建一个 Spring <form:input>。我已经看到如何使用List:
<form:form>
<c:forEach items="${itemList}" var="item" varStatus="status" >
<form:input path="itemList[${status.index}].name" />
</c:forEach>
</form:form>
我的问题是我使用的是无序的Set,我不相信我可以使用index 属性。将Set 的内容添加到 Spring 绑定表单的最佳实践是什么?我想我只需要转换为List,但我对任何可能的替代方案都很感兴趣。
【问题讨论】:
-
就我而言,我必须从 jsp 页面获取列表中每个用户的已检查属性,因此我必须在表单支持对象中使用该列表,有人可以帮助我吗那,这是我的问题的链接stackoverflow.com/q/11478816/1458508
-
以上 JSP 代码在 Websphere 中不起作用,出现以下错误。
org.springframework.beans.NotReadablePropertyException: Invalid property 'xxxx[0]' of bean class [com.xxx.yyy.conf.xxxx]: Bean property 'xxxx[0]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? -
在 Websphere 7 应用服务器中有人对此有疑问吗?
标签: java data-binding spring-mvc jstl