Take the 2-minute tour ×

I have a list of Strings that are attribute names and 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">
    <s:iterator value="attributeList" var="attrName">
      <td><p><s:property value="#element.Project.#attrName" /></p></td>

If I hard code the attribute name it works fine:

<td><p><s:property value="#element.Project.projectName" /></p></td>

Any advice is appreciated.

share|improve this question
I have no utter idea about Struts2/OGNL, but in standard JSP EL it is possible by brace notation like ${element.project[attrName]}. –  BalusC Feb 18 '11 at 15:57
Well. That also did the trick for me. Thanks –  Daniel Kim Feb 18 '11 at 16:18
This answer has proven to be useful already. Great Stuff. –  Alex Feb 20 '11 at 12:22
add comment

1 Answer

Using OGNL <s:property value="#element.Project[#attrName]" />

share|improve this answer
add comment

Your Answer


