I. Traversing a map type
1. First look at the background Java program
Java code
Copy Code code as follows:
Map<string,string> paramvalues=new hashmap<string, string> ();
***
The middle assignment operation omitted the
***
Data.put ("Paramvalues", paramvalues);//pass value to velocity
2. Take out the key and value of this map in the velocity template file of the foreground
Java code
Copy Code code as follows:
#foreach ($param in ${paramvalues.keyset ()})
<tr>
<th> $param </th>
<td>${paramvalues.get ($param)}</td>
</tr>
#end
two. Traverse List Type
1. First look at the background Java code
Java code
Copy Code code as follows:
List<saler> salerlist=new arraylist<saler> ();
***
The middle assignment operation omitted the
***
Data.put ("Salerlist", salerlist);//pass value to velocity
2. See the code in the Velocity template again
Copy Code code as follows:
#foreach ($sal in ${salerlist})
$sal. Name
#end