Spring – c:foreach and hibernate’s maps / lists

iterating over a list / set can be done via;

<c:forEach items=”${job.jobPhotos}” var=”photo” varStatus=”idx”>
<form:hidden path=”jobPhotos[${idx.index}].id” />

Iterating over a map can be done via;

<c:forEach items=”${job.jobPhotos}” var=”current”>
<form:hidden path=”jobPhotos[${current.key}].id” />

${current.key} and ${current.value.id} are equilivant (both equate to the ID of the row being iterated over)


Hibernate Annotations – Bidirectional One-To-Many

Leave a Reply