问题
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