我想显示一个列表给用户的编辑,如何进行绑定呢?想要的效果(DisplayName是一个输入框,用户能修改):
ID Name DisplayName
1 A D - A
2 B D - B
3 C D - C
...Command Class
Class UserForm {
private List<User> users;
public setUsers(List users) {...}
public List getUsers() {...}
}User class
Class User {
private String id;
private String name;
private String displayName;
...
}AmendUser.jsp
...
<form:form commandName="userForm">
<table>
<tr>
<td>ID</td>
<td>Name</td>
<td>Display Name</td>
</tr> <c:forEach var="user" items="${users}">
<tr>
<td>${user.id></td>
<td>${user.name}</td>
<td><form:input path="user.displayName"/></td>
</tr>
</c:forEach>
</table>
</form:form>如果使用上面的绑定,回出现以下异常:
Bean property 'user' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?请问如何解决在循环中的绑定问题?
ID Name DisplayName
1 A D - A
2 B D - B
3 C D - C
...Command Class
Class UserForm {
private List<User> users;
public setUsers(List users) {...}
public List getUsers() {...}
}User class
Class User {
private String id;
private String name;
private String displayName;
...
}AmendUser.jsp
...
<form:form commandName="userForm">
<table>
<tr>
<td>ID</td>
<td>Name</td>
<td>Display Name</td>
</tr> <c:forEach var="user" items="${users}">
<tr>
<td>${user.id></td>
<td>${user.name}</td>
<td><form:input path="user.displayName"/></td>
</tr>
</c:forEach>
</table>
</form:form>如果使用上面的绑定,回出现以下异常:
Bean property 'user' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?请问如何解决在循环中的绑定问题?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货