Getting List for Select tag from Map<List<Object>> based on iterator index

梦想与她 提交于 2020-01-03 05:09:49

问题


I have a Map containing Lists like below.

Map<String,List<Object>> dynamicList = new HashMap <String,List<Object>>();

In the above Map I have keys like dynamiclist1, dynamiclist5, dynamiclist6, etc.

I have to show this dynamicList based on another iterator index like below:

<s:iterator value="listOne" var="list" status="stat">
    <s:select name="col%{#stat.index}" 
              listKey="KEY" 
              listValue="VALUE" 
              list="#dynamicList.dynamiclist%{#stat.index}" />
</s:iterator>

I want something like this #dynamicList.dynamiclist%{#stat.index} to get that list.


回答1:


When iterating a map via the iterator tag var attribute is not necessary, because the current item pushed to the value stack on each iteration. So, referencing value attribute of the map entry as a list collection.

<s:iterator value="listOne" status="stat">
    <s:select name="col%{#stat.index}" 
              listKey="KEY" 
              listValue="VALUE" 
              list="dynamicList['%{top}']" />
</s:iterator>


来源:https://stackoverflow.com/questions/18613787/getting-list-for-select-tag-from-maplistobject-based-on-iterator-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!