Accessing Map attribute with dynamic key in Struts 2 OGNL
I have a list of Strings that are attribute names an开发者_开发技巧d a Map. I'm trying to access a model(ex.project) in the map using attribute name in string list.
Here is what I have now.
<s:iterator value="theMap" var="element">
<tr>
<s:iterator value="attributeList" var="attrName">
<td><p><s:property value="#element.Project.#attrName" /></p></td>
</s:iterator>
</tr>
</s:iterator>
If I hard code the attribute name it works fine:
<td><p><s:property value="#element.Project.projectName" /></p></td>
Any advice is appreciated.
Using OGNL <s:property value="#element.Project[#attrName]" />
精彩评论