I recently encountered some problems when I used jsp to output map data.
The result is that I didn't set the get Method for map in ation (all I have is the ssh framework)
Assume that there is a map variable in the action, and the key-value pair is a set of String and Custom User types, respectively.
Action has the following code, and the action contains the map attribute, map set, and get methods.
Map <String, List <User> map = new HashMap <String, List <User> ();
User user = new User ();
User. setId = 1;
User. setName = "aa ";
List <User> list1 = new ArrayList <User> ();
List1.add (user );
User user2-new User ();
User2.setId = 2;
User2.setName = "bb ";
List1.add (user2 );
User user3 = new User ();
User3.setId = 3;
User3.setName = "cc ";
List <User> list2 = new ArrayList <User> ();
List1.add (user3 );
User user4-new User ();
User4.setId = 4;
User4.setName = "cc ";
List2.add (user4 );
Map. put ("group1", list1 );
Map. put ("group2", list2 );
What should I do if I want to traverse list1 in jsp?
Use struts2 labels
<S: iterator value = "map ['group1']">
<S: property value = "id"/>:< s: property value = "name"/>
<Br/>
</S: iterator>
The page will output
1: aa
2: bb