问题
HI,
Here's my dilemma. The below code is obviously wrong but it give you the idea on what I need to accomplish.
<c:forEach var="object1" items="${model.listofObjects1}">
<tr>
<c:forEach var="object2" items="${model.listofObjects2}">
<td>${object1.${object2}}</td>
</c:forEach>
</tr>
</c:forEach>
Any ideas on how to make this look up?
回答1:
Use the brace notation.
<td>${object1[object2]}</td>
来源:https://stackoverflow.com/questions/4957685/how-to-get-a-value-of-an-objects-property-when-the-property-name-is-a-variable