I have a list of list of objects and i am putting this nested list inside ModelandView
object but I am not able to acccess the list on the JSP page.
<c:forEach items="${product.productCategoryDetails}" var="productCategoryDetails" varStatus="status">
<tr id="category_row">
<td><form:label path="productCategoryDetails[${status.index}].category">Category</form:label></td>
<td>
<form:select cssStyle="width:134px" path="productCategoryDetails[${status.index}].category.id" cssClass="category">
<form:options items="${categories}" itemValue="id" itemLabel="name"/>
</form:select>
</td>
<td><form:label path="productCategoryDetails[${status.index}].subcategory">SubCategory</form:label></td>
<td>
<form:select cssStyle="width:134px" path="productCategoryDetails[${status.index}].subcategory.id" cssClass="subcategory">
<form:options items="${subCategories}" itemValue="id" itemLabel="name"/>
</form:select>
</td>
</tr>
</c:forEach>
Code is working perfectly for categories but it is breaking for subcategories.
modelandview.put("subCategories", subCategories);
here, subCategories
is a list of list of SubCategory
objects.
Also, ProductCategoryDetail
object has Category
and SubCategory
fields.