请帮助解决这个问题,我无法更新封装在对象列表中的对象属性的值,我在下面已经解释过,我的代码确实面临问题。
我有一个java bean类(User),它有对象List(ReferenceBean),这个列表的值将由database访问。每个ReferenceBean Objec都有另一个对象(UserAssociate)。我需要更新UserAssociate对象属性的值。
用户类:
public class User implements Serializable{
private String userName;
private String fullName;
private List<ReferenceBean> references;
//corresponding getter,setter methods.
}
ReferenceBean类:
public class ReferenceBean implements Serializable{
boolean add;
boolean modify;
boolean delete;
UserAssociate userAssociate;
//corresponding getter,setter methods.
}
UserAssociate class:
public class UserAssociate implements Serializable {
int moduleCode;
boolean add;
boolean modify;
boolean delete;
//corresponding getter,setter methods.
}
下面是我的jsp页面。我正在使用SpringMVC,在jsp页面中我设置了modelAttribute =&#34; user&#34;从控制器层读取其值。 这里成功获取了数据库中的值,但是无法更新UserAssociate属性的值(复选框)。(尝试使用路径属性也无法实现)。
<tr><td>
Full Name<form:input path="fullName" />
</td></tr>
<tr><td>
User Name<form:input path="userName" />
</td></tr>
<table class="tableNew">
<tr>
<td><b> Add </b></td>
<td><b>Modify</b></td>
<td><b>Delete </b></td>
</tr>
<c:forEach var="ref" items="${user.references}">
<tr>
<td><c:if test="${ref.isAdd()}">
<c:choose>
<c:when test="${ref.userAssociate.isAdd()}">
<input type="checkbox" checked="checked">
</c:when>
<c:otherwise>
<input type="checkbox" />
</c:otherwise>
</c:choose></c:if></td>
<td><c:if test="${ref.isModify()}">
<c:choose>
<c:when test="${ref.userAssociate.isModify()}">
<input type="checkbox" checked="checked">
</c:when>
<c:otherwise>
<input type="checkbox" />
</c:otherwise>
</c:choose></c:if></td>
<td><c:if test="${ref.isDelete()}">
<c:choose>
<c:when test="${ref.userAssociate.isDelete()}">
<input type="checkbox" checked="checked">
</c:when>
<c:otherwise>
<input type="checkbox" />
</c:otherwise>
</c:choose></c:if></td>
</tr>
</c:forEach>
</table>