1
我已經搜索了幾個例子,仍然沒有得到。我將一個來自控制器的GOOD對象列表傳遞給jsp頁面。在這個對象中,我有UserName和另一個對象FUNCTIONS列表。我想遍歷GOOD列表並希望顯示名稱和相應的功能,但無法這樣做。 我的好豆是:需要幫助迭代列表中的列表對象在春天mvc
public List<Function> userFunctionsList = new ArrayList<Function>();
public String userName;
我訪問bean是:
public List<Good> goodBeanList = new ArrayList<Good>();
public List<Good> getGoodBeanList() {
return goodBeanList;
}
public void setGoodBeanList(
List<Good> goodBeanList) {
this.goodBeanList = goodBeanList;
}
我的控制器類:
public ModelAndView getUserDetails(PortletRequest request, PortletResponse response)
{
List<Good> searchedUsersList = null;
List<Good> finalList = new ArrayList<ManageCorporateServices>();
Access accessBean = new Access();
searchedUsersList = goodService.getSearchedUsers(contractId,userName);
for(Good goodBean : searchedUsersList)
{
userFunctionsList = goodService.getUserFunctions(goodBean.getUserName());
goodBean.setUserFunctionsList(userFunctionsList);
finalList.add(goodBean);
}
access.setGoodBeanList("finalList");
modelAndView.adObject("access",access);
在JSP:
<form:form commandName="access" action="${updateFunctionNew}">
<c:forEach var="userNamesListValue" items="${access.goodBeanList }">
<tr>
<td>
<a href="${selectedUserName}" title="selectedUserName">${userNamesListValue.userName}</a>
</td>
<c:forEach varStatus = "count" var="userFunctionsList" items="${userNamesListValue.userFunctionsList}">
<td>${userFunctionsList.functionName} <form:checkbox path="userFunctionsList[${count.index }].updatedValue" value="${userFunctionsList.updatedValue}" /></td>
</c:forEach>
<td><button type="Submit" class="pink">Save</button>
</td>
</tr>
</c:forEach>
</form:form>
我越來越userFunctionsList [0] n Access Bean錯誤中的可讀屬性。有人請幫助我。
現在它投擲無效的屬性「userNamesListValue [0]」 bean類[com.Access]的:Bean屬性「userNamesListValue [0]」是不可讀的或有一個無效getter方法:是否的返回類型吸氣劑與吸氣劑的參數類型相匹配? – user3592257 2014-11-25 11:53:05
確保你有bean的getter和setter,請參閱我的編輯 – 2014-11-25 12:41:19
我在bean中有getter/setter。我沒有在這篇文章中提到可讀性。 – user3592257 2014-11-25 12:57:41