怎么在Struts2中利用OGNL表达式对map进行遍历-创新互联

这篇文章给大家介绍怎么在Struts2中利用OGNL表达式对map进行遍历,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

龙潭ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

一.Action中的代码:MapAction.java

package com.zx.demo.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.opensymphony.xwork2.ActionSupport;
import com.zx.demo.model.Product;
import com.zx.demo.model.Student;
public class MapAction extends ActionSupport
{  
 private Map map;
 private Map studentMap;
 private Map arrayMap;
 private Map> listMap;  
 //这里省略get set方法
 public String testMap(){  
map=new HashMap();
 map.put("1", "one");
 map.put("2", "two");
studentMap=new HashMap();
studentMap.put("student1",new Student(new Long(1),"20034140201","张三1","男",25));
studentMap.put("student2",new Student(new Long(2),"20034140202","张三2","女",26));
studentMap.put("student3",new Student(new Long(3),"20034140202","张三3","男",27));
arrayMap=new HashMap();
arrayMap.put("arr1", new String[]{"1","2003401","leejie","male","20"});
arrayMap.put("arr2", new String[]{"2","2003402","huanglie","male","25"});
arrayMap.put("arr3", new String[{"3","2003403","lixiaoning","male","21"});
listMap=new HashMap>();
  List list1=new ArrayList();
list1.add(new Student(new Long(1),"20034140201","张三1","男",25));
list1.add(new Student(new Long(2),"20034140202","张三2","男",25));
list1.add(new Student(new Long(3),"20034140203","张三3","男",25));
  listMap.put("class1", list1);
 List list2=new ArrayList();
list2.add(new Student(new Long(1),"20034140301","李四1","男",20));
list2.add(new Student(new Long(2),"20034140302","李四2","男",21));
list2.add(new Student(new Long(3),"20034140303","李四3","男",22));
list2.add(new Student(new Long(4),"20034140304","李四4","男",23));
  listMap.put("class2", list2);
return SUCCESS;  
  }  
}

文章标题:怎么在Struts2中利用OGNL表达式对map进行遍历-创新互联
文章起源:http://bzwzjz.com/article/dohieo.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 梓潼网站设计 成都网站设计 四川成都网站设计 高端定制网站设计 成都定制网站建设 成都网站设计制作公司 高端网站设计推广 企业手机网站建设 高端网站设计 定制网站建设 手机网站建设 成都营销网站制作 手机网站建设 品牌网站建设 成都网站建设 成都网站建设公司 成都商城网站建设 定制网站设计 成都网站建设公司 成都网站建设 营销型网站建设 企业网站制作