我的代码被卡住了,我需要帮助。我想访问jsp页面中arraylist的属性。下面给出的是代码片段和错误。任何帮助都将不胜感激!
public class Policydocumentsetform implements Serializable{
...
private ArrayList<Document> documentList;
...
}
public class Document implements Serializable{
...
private String txtDisableCheckBox;
private String ynChkBox;
...
}
<c:forEach var="documentlist" items="${policydocumentsetform.documentList}">
<c:if test="${documentlist.txtDisableCheckBox=='N'}">
<form:checkbox path="documentlist.ynChkBox" cssClass="genradio" value="-1" onclick="selectCheckBox(event.keyCode,this)"/>
org.springframework.beans.NotReadablePropertyException: Invalid property 'documentlist' of bean class [gc.dms.bean.PolicyDocumentSetForm]
异常:
org.springframework.beans.NotReadablePropertyException: Invalid property 'documentlist' of bean class [gc.dms.bean.PolicyDocumentSetForm]
可能在中
<form:checkbox path="documentlist.ynChkBox" //Here, is the problem
cssClass="genradio"
value="-1"
onclick="selectCheckBox(event.keyCode,this)"/>
解决方案,
我认为你已经将Policydocumentsetform
添加为commandName
或modelAttribute
,并尝试使用spring复选框(<form:checkbox..
),如果是这样,请喜欢:
<form:form commandName="policydocumentsetform"...>
<c:forEach var="document" items="${policydocumentsetform.documentList}" varStatus="documentLoop">
<c:if test="${document.txtDisableCheckBox=='N'}">
<form:checkbox path="documentList[${documentLoop.index}].ynChkBox"
cssClass="genradio"
value="-1"
onclick="selectCheckBox(event.keyCode,this)"/>
</c:if>
</c:forEach>
注意:确保getter和setter在Policydocumentsetform
和Document
中可用