Struts2中iterator标签遍历m…
来源:互联网 发布:崔万志淘宝店 编辑:程序博客网 时间:2024/05/17 23:37
原文地址:Struts2中iterator标签遍历map总结(转)作者:雪后DE阳光
1.MapAction.java
2.testMap.jsp
Java代码
- package com.zx.demo.action;
-
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- importcom.opensymphony.xwork2.ActionSupport;
- importcom.zx.demo.model.Product;
- importcom.zx.demo.model.Student;
-
- public class MapActionextends ActionSupport
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
{ -
map= -
map.put( -
map.put( -
-
studentMap= -
studentMap.put( -
studentMap.put( -
studentMap.put( -
-
arrayMap= -
arrayMap.put( -
arrayMap.put( -
arrayMap.put( -
-
-
-
listMap= -
-
List<Student>list1= -
list1.add( -
list1.add( -
list1.add( -
listMap.put( -
-
List<Student>list2= -
list2.add( -
list2.add( -
list2.add( -
list2.add( -
listMap.put( -
-
-
-
-
-
-
} -
-
-
-
-
-
} -
-
-
-
} -
-
-
-
} -
-
-
-
} -
-
-
-
-
} -
-
-
-
-
} -
-
-
-
-
-
} -
-
-
-
-
-
} -
-
- }
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<String,String> map; private Map<String,Student> studentMap; private Map<String,String[]> arrayMap; private Map<String,List<Student>> listMap; public String testMap() { map=new HashMap<String,String>(); map.put("1", "one"); map.put("2", "two"); studentMap=new HashMap<String,Student>(); 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<String,String[]>(); 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<String,List<Student>>(); List<Student> list1=new ArrayList<Student>(); 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<Student> list2=new ArrayList<Student>(); 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; } public Map<String, String> getMap() { return map; } public void setMap(Map<String, String> map) { this.map = map; } public Map<String, Student> getStudentMap() { return studentMap; } public void setStudentMap(Map<String, Student> studentMap) { this.studentMap = studentMap; } public Map<String, String[]> getArrayMap() { return arrayMap; } public void setArrayMap(Map<String, String[]> arrayMap) { this.arrayMap = arrayMap; } public Map<String, List<Student>> getListMap() { return listMap; } public void setListMap(Map<String, List<Student>> listMap) { this.listMap = listMap; } }
2.testMap.jsp
Java代码
- <%@ pagecontentType="text/html;charset=UTF-8"%>
- <%@ taglib prefix="s"uri="/struts-tags" %>
- <html>
- <head>
- <title>struts2中的map遍历总结</title>
- </head>
- <body>
-
<b> -
<s:iterator value= -
<s:property value= -
key: <s:property value= -
value:<s:property value= -
******************************************<br> -
</s:iterator> -
-
-
<b> -
<table border= cellspacing= -
<tr> -
<td>key=value</td> -
<td>ID</td> -
<td>num</td> -
<td>name</td> -
<td>sex</td> -
<td>age</td> -
</tr> -
<s:iterator value= -
<tr> -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
</tr> -
</s:iterator> -
</table> -
<p> -
-
-
<b> -
<table border= cellspacing= -
<tr> -
<td>key=value</td> -
<td>ID</td> -
<td>num</td> -
<td>name</td> -
<td>sex</td> -
<td>age</td> -
</tr> -
<s:iterator value= -
<tr> -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
</tr> -
</s:iterator> -
</table> -
<p> -
<b> -
<table border= cellspacing= -
<tr> -
<td> -
<td>ID</td> -
<td>num</td> -
<td>name</td> -
<td>sex</td> -
<td>age</td> -
</tr> -
-
<s:iterator value= -
<s:set name= -
<s:iterator value= -
<tr> -
<s: -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
<td><s:propertyvalue= -
</tr> -
</s:iterator> -
</s:iterator> - </table>
-
-
- </body>
- </html>
0 0
- Struts2中iterator标签遍历m…
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结
- Struts2中iterator标签遍历map总结(转)
- java学习心得
- Dreamweaver8简体中文版注册码
- j2ee三大框架个人理解
- 求出1+2+3+...n<8888 中的最大的n…
- Struts2操作Request、Session和App…
- Struts2中iterator标签遍历m…
- struts2中struts.xml什么时候加载…
- struts拦截器的功能详解
- 拦截器与过滤器的区别
- struts2 服务器转发与客户端跳转写…
- js分页{此贴转载的地方忘啦。不好…
- 分页算法求总页数
- Struts2token防止重复提交引用csdn…
- 数据库超时