Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming...
The fourth application example of velocity-traversing the Map set
// 2 Create a Context objectVelocityContext context = newVelocityContext (); // 3 Add you data objects to this contextMap
Map = newHashMap
(); Map. put ("key1", "value1"); map. put ("key2", "value2"); map. put ("key3", "value3"); map. put ("key4", "value4"); context. put ("map", map); // 4 Choose a templateTemplate template = Velocity. getTemplate ("map. vm "); // 5 Merge the template and you data toproduce the outputStringWriter sw = new StringWriter (); template. merge (context, sw); sw. flush (); System. out. println (sw. toString ());
Template
# Foreach ($ keyin $ map. keySet () $ key: $ map. get ($ key) # end ======
The above is the content. For more information, please follow the PHP Chinese network (www.php1.cn )!