Struts2中iterator标签遍历map总结

Struts2中iterator标签遍历map总结 收藏

Struts2中iterator标签遍历map总结

针对以下几种情况的Map:

private Map map;

private Map studentMap;

private Map arrayMap;

private Map> listMap;

--------------------------------------------------------------------------------

map=new HashMap();

map.put("1", "one");

map.put("2", "two");

用法:

key:

value:

--------------------------------------------------------------------------------

studentMap=new HashMap();

studentMap.put("student1",new Student(new Long(1),"[1**********]","张三1","男",25));

studentMap.put("student2",new Student(new Long(2),"[1**********]","张三2","女",26));

studentMap.put("student3",new Student(new Long(3),"[1**********]","张三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),"[1**********]","张三1","男",25));

list1.add(new Student(new Long(2),"[1**********]","张三2","男",25));

list1.add(new Student(new Long(3),"[1**********]","张三3","男",25));

listMap.put("class1", list1);

List list2=new ArrayList();

list2.add(new Student(new Long(1),"[1**********]","李四1","男",20));

list2.add(new Student(new Long(2),"[1**********]","李四2","男",21));

list2.add(new Student(new Long(3),"[1**********]","李四3","男",22));

list2.add(new Student(new Long(4),"[1**********]","李四4","男",23));

listMap.put("class2", list2);

用法:

Struts2中iterator标签遍历map总结 收藏

Struts2中iterator标签遍历map总结

针对以下几种情况的Map:

private Map map;

private Map studentMap;

private Map arrayMap;

private Map> listMap;

--------------------------------------------------------------------------------

map=new HashMap();

map.put("1", "one");

map.put("2", "two");

用法:

key:

value:

--------------------------------------------------------------------------------

studentMap=new HashMap();

studentMap.put("student1",new Student(new Long(1),"[1**********]","张三1","男",25));

studentMap.put("student2",new Student(new Long(2),"[1**********]","张三2","女",26));

studentMap.put("student3",new Student(new Long(3),"[1**********]","张三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),"[1**********]","张三1","男",25));

list1.add(new Student(new Long(2),"[1**********]","张三2","男",25));

list1.add(new Student(new Long(3),"[1**********]","张三3","男",25));

listMap.put("class1", list1);

List list2=new ArrayList();

list2.add(new Student(new Long(1),"[1**********]","李四1","男",20));

list2.add(new Student(new Long(2),"[1**********]","李四2","男",21));

list2.add(new Student(new Long(3),"[1**********]","李四3","男",22));

list2.add(new Student(new Long(4),"[1**********]","李四4","男",23));

listMap.put("class2", list2);

用法:


相关文章

  • JAVA复试问题答案
  • (一) JAVA复试的问题整理 1 Hibernate 的优化流程是如何实现的,流程是怎么样? 1. 尽量使用many-to-one ,避免使用单向one-to-many 象 2 Struts1与Struts2的区别? 在Action 实现 ...查看


  • STL实践指南 作者 Jeff Bogan
  • 原作者姓名 Jeff Bogan 介绍 这是一篇指导您如何在Microsoft Visual Studio下学习STL并进行实践的文章.这篇文章从STL的基础知识讲起,循序渐进,逐步深入,涉及到了STL编写代码的方法.STL代码的编译和调试 ...查看


  • 大唐电信java笔试题及答案
  • 1. Java如何实现多态,实现的主要方法. java是借助方法的重写和重载实现多态. 重载的特性,方法名相同.返回类型,传入方法的参数不同(包括个数和类型). 重写的特性,方法名相同,返回类型,参数均相同,必须发生在子类. 2. Hash ...查看


  • 增强for循环和普通for循环的区别
  • 此处引用 ----------- 1.增强for循环和iterator遍历的效果是一样的,也就说 增强for循环的内部也就是调用iteratoer实现的(可以查看编译后的文件),但是增强for循环 有些缺点,例如不能在增强循环里动态的删除集 ...查看


  • DBSCAN聚类算法原理及其实现
  • DBSCAN(Density-Based Spatial Clustering of Applications with Noise)聚类算法,它是一种基于高密度连通区域的.基于密度的聚类算法,能够将具有足够高密度的区域划分为簇,并在具有噪 ...查看


  • 集合练习题
  • 1. 填空 Collection 接口的特点是元素是___对象______: List 接口的特点是元素__有___(有|无)顺序,___不可以___(可以|不可以)重复: Set 接口的特点是元素__无___(有|无)顺序,__可以___ ...查看


  • 泛型算法 (输入输出迭代器和算法综合介绍)
  • 第十一章 泛型算法 标准库容器定义的操作非常少.标准库没有给容器添加大量的功能函数,而是选择提供一组算法,这些算法大都不依赖特定的容器类型,是"泛型"的,可作用在不同类型的容器和不同类型的元素上. 考虑下面的例子,可以使 ...查看


  • 三大框架工作流程
  • Hibernate的工作流程: 1.         读取并解析配置文件 2.         读取并解析映射信息,创建SessionFactory 3.         打开Sesssion 4.         创建事务Transati ...查看


  • 自己实现文本相似度算法(余弦定理)
  • 最近由于工作项目,需要判断两个txt文本是否相似,于是开始在网上找资料研究,因为在程序中会把文本转换成String再做比较,所以最开始找到了这篇关于 距离编辑算法 Blog写的非常好,受益匪浅. 于是我决定把它用到项目中,来判断两个文本的相 ...查看


热门内容