博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Struts2中iterator标签遍历map list总结
阅读量:5106 次
发布时间:2019-06-13

本文共 4217 字,大约阅读时间需要 14 分钟。

1  package com.zx.demo.action; 2 import java.util.ArrayList; 3 import java.util.HashMap; 4 import java.util.List; 5 import java.util.Map; 6 import com.opensymphony.xwork2.ActionSupport; 7 import com.zx.demo.model.Product; 8 import com.zx.demo.model.Student; 9 public class MapAction extends ActionSupport10 {11     private Map
map;12 13 private Map
studentMap;14 15 private Map
arrayMap;16 17 private Map
> listMap;18 19 public String testMap()20 {21 map=new HashMap
();22 map.put("1", "one");23 map.put("2", "two");24 25 studentMap=new HashMap
();26 studentMap.put("student1",new Student(new Long(1),"20034140201","张三1","男",25));27 studentMap.put("student2",new Student(new Long(2),"20034140202","张三2","女",26));28 studentMap.put("student3",new Student(new Long(3),"20034140202","张三3","男",27));29 30 arrayMap=new HashMap
();31 arrayMap.put("arr1", new String[]{"1","2003401","leejie","male","20"});32 arrayMap.put("arr2", new String[]{"2","2003402","huanglie","male","25"});33 arrayMap.put("arr3", new String[]{"3","2003403","lixiaoning","male","21"});34 35 36 37 listMap=new HashMap
>();38 39 List
list1=new ArrayList
();40 list1.add(new Student(new Long(1),"20034140201","张三1","男",25));41 list1.add(new Student(new Long(2),"20034140202","张三2","男",25));42 list1.add(new Student(new Long(3),"20034140203","张三3","男",25));43 listMap.put("class1", list1);44 45 List
list2=new ArrayList
();46 list2.add(new Student(new Long(1),"20034140301","李四1","男",20));47 list2.add(new Student(new Long(2),"20034140302","李四2","男",21));48 list2.add(new Student(new Long(3),"20034140303","李四3","男",22));49 list2.add(new Student(new Long(4),"20034140304","李四4","男",23));50 listMap.put("class2", list2);51 52 53 54 55 return SUCCESS;56 57 }58 59 60 public Map
getMap() {61 return map;62 }63 public void setMap(Map
map) {64 this.map = map;65 }66 67 public Map
getStudentMap() {68 return studentMap;69 }70 public void setStudentMap(Map
studentMap) {71 this.studentMap = studentMap;72 }73 public Map
getArrayMap() {74 return arrayMap;75 }76 public void setArrayMap(Map
arrayMap) {77 this.arrayMap = arrayMap;78 }79 public Map
> getListMap() {80 return listMap;81 }82 public void setListMap(Map
> listMap) {83 this.listMap = listMap;84 }85 86 87 }
1  <%@ page contentType="text/html;charset=UTF-8" %> 2 <%@ taglib prefix="s" uri="/struts-tags" %> 3  4  5 struts2中的map遍历总结 6  7  8    1.map中的value为String字符串
9
10
11 key:
12 value:
13 ******************************************
14
15 16 17 2.map中的value为Student对象18
28
19
20
21
22
23
24
25
26
27
29
30
31
32
33
34
35
36 37
key=value ID num name sex age
38

39 40 41 3.map中的value为String数组42

52
43
44
45
46
47
48
49
50
51
53
54
55
56
57
58
59
60 61
key=value ID num name sex age
62

63 4.map中的value为list集合64

75
76
77
65
66
67
68
69
70
71
72
73 74
78
79
80
81
82
83
84
85 86 87
class ID num name sex age
88 89 90 91

 

转载于:https://www.cnblogs.com/XL-Liang/archive/2013/03/29/2988783.html

你可能感兴趣的文章
aboutMe
查看>>
【Debug】IAR在线调试时报错,Warning: Stack pointer is setup to incorrect alignmentStack,芯片使用STM32F103ZET6...
查看>>
一句话说清分布式锁,进程锁,线程锁
查看>>
Hash和Bloom Filter
查看>>
SQL Server获取月度列表
查看>>
python常用函数
查看>>
python 描点画圆
查看>>
FastDFS使用
查看>>
服务器解析请求的基本原理
查看>>
pycharm 如何设置方法调用字体颜色
查看>>
VUE源码解析心得
查看>>
[HDU3683 Gomoku]
查看>>
【工具相关】iOS-Reveal的使用
查看>>
整体二分——[Poi2011]Meteors
查看>>
数据库3
查看>>
delphi之事件
查看>>
windows server 2008 r2 安装
查看>>
存储分类
查看>>
下一代操作系统与软件
查看>>
【iOS越狱开发】如何将应用打包成.ipa文件
查看>>