您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

velocity第四个应用例子---遍历Map集合

2024/4/8 6:29:49发布12次查看
velocity第四个应用例子---遍历map集合
//2 create a context object velocitycontext context = newvelocitycontext(); //3 add you data objects to this context map<string,string> map = newhashmap<string,string>(); map.put("key1","value1"); map.put("key2","value2"); map.put("key3","value3"); map.put("key4","value4"); context.put("map", map); //4 choose a template template template =velocity.gettemplate("map.vm"); //5 merge the template and you data toproduce the output stringwriter sw = new stringwriter(); template.merge(context, sw); sw.flush(); system.out.println(sw.tostring());
模板
#foreach($keyin $map.keyset()) $key:$map.get($key) #end ========
以上就是的内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product