velocity获取list,map以及list套map中数据
来源:互联网 发布:什么照相软件好 编辑:程序博客网 时间:2024/05/08 05:39
1.velocity 获取list 中的值
VelocityEngine veloEngine = new VelocityEngine();
Template template = veloEngine.getTemplate(xmlPath, "UTF-8");
VelocityContext velocityContext = new VelocityContext();
List<Object> list = new ArrayList<Object>();
list.add("1");
list.add("2");
velocityContext.put("list", list);
XML中写法为
#foreach($data in $list)
<risk>
<age>$!data </age> @$!其中!代表非空时取值,避免值为空时显示为data
</risk>
#end
2.velocity 获取map 中的值
Map<String,Object> map = new HashMap<String,Object>();
map.put("age", "11");
map.put("sex","男");
velocityContext.put("data", map);
XML中写法为
<age>$!data.age</age>
<sex>$!data.sex</sex>
List<Object> list = new ArrayList<Object>();
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("age", "11");
Map<String, Object> map3 = new HashMap<String, Object>();
map3.put("age", "22");
map3.put("bname", "bname");
list.add(map2);
list.add(map3);
Map<String, Object> map = new HashMap<String, Object>();
map.put("list", list);
velocityContext.put("data", map);
XML中写法为
#foreach ($lis in ${data}) @第一次循环获取list
#foreach( $aa in $lis) @然后将lis循环获取变量
<risk>
<age>$!aa.age </age>
<age>$!aa.bname </age>
</risk>
#end
#end
- velocity获取list,map以及list套map中数据
- velocity map list 遍历
- velocity 中Map 和List 循环
- Velocity遍历List和Map
- Velocity遍历List和Map
- Velocity遍历List和Map
- velocity map list 数组操作
- Velocity遍历List和Map
- velocity 显示List和Map方法
- velocity 显示List和Map方法
- Velocity遍历map与遍历list
- Map中取list
- 遍历List<map<>>以及map方法
- [WEB前端开发]-关于Velocity中Map与List操作-解决velocity无法识别Map对象key的问题
- list map中的value获取
- list map中的value获取
- List&Map
- list map
- 实现子div在父div的底部
- java netty 服务端向客户端发送16进制数据,客户端无法接收-已解决
- loadrunner之系统资源分析
- MyBatis 判断条件为等于的问题(<if test="type == '1'.toString()"> xxx </if>
- PHP性能优化分析
- velocity获取list,map以及list套map中数据
- 详解跨域请求的两种方式,支持post请求
- hadoop(二):hdfs HA原理
- 运行tensorflow基本程序mnist.py
- First Step
- 原创性博文导航
- Full details will be found in the appropriate container log 解决办法
- md5碰撞备注
- FTP服务器搭建的几种方式<二>