开发者

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]" />

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜