About JSP using El and struts2 tags to traverse valuestack's dongdong------> List<map<k,v>> and map<k,<list<xxx>>> The structure traversal

Source: Internet
Author: User

The first structure of map<k,<list<xxx>>>
<Body> <%//Show Map<string,list<object>> Map map = new HashMap<String, List<string>> (); List List = new ArrayList<String>(); List.add ("List1-1"); List.add ("List1-2"); List.add ("List1-3"); List list2 = new ArrayList<String>(); List2.add ("list2-1"); List2.add ("list2-2"); List2.add ("list2-3"); Map.put ("A", list); Map.put ("B", List2); Actioncontext.getcontext (). Getvaluestack (). Request.setattribute ("Map1", map); %><%out.print("HelloWorld for testing the traversal of the map and list value stacks"); %> <S:iteratorvalue= "#request. Map1"var= "List">Map_key:<S:propertyvalue= "#list. Key"/></BR> <S:iteratorvalue= "#list. Value"var= "Current">List Value:<S:propertyvalue= "Current"/></BR> </S:iterator> </S:iterator> </Body>


Print results
HelloWorld for testing the traversal of the map and list value stacks

Map_key:b
List value: list2-1
List value: list2-2
List value: list2-3
Map_key:a
List value: List1-1
List value: List1-2
List value: List1-3


The second structure of list<map<k,v>>

<% ListList= newarraylist<map<string,string>> (); Map map1 = new HashMap<String, String>(); Map1.put ("A", "map1-1"); Map1.put ("B", "map1-2"); Map map2 = new HashMap<String, String>(); Map2.put ("A", "map2-1"); Map2.put ("B", "map2-2"); Map2.put ("C", "map2-3"); List.add (MAP1); List.add (MAP2); Put it in the root stack rather than the map stack//Actioncontext.getcontext (). Getvaluestack (). push (list); Request.setattribute ("list", list); %><S:debug></S:debug> <%out.print("HelloWorld for testing the traversal of the map and list value stacks"); %> <S:iteratorvalue= "#request. List"var= "List1"></BR> <S:iteratorvalue= "#list1"var= "Map" ></BR> <S:propertyvalue= "#map. Key"/> <S:propertyvalue= "#map. Value"/> </S:iterator>


Print results
HelloWorld for testing the traversal of the map and list value stacks

b map1-2
A map1-1

b map2-2
C map2-3
A map2-1

About JSP using El and struts2 tags to traverse valuestack------> List<map<k,v>> and map<k,<list<xxx>> > 's Structure traversal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.