Struts2中iterator标签遍历m…

从零开始:用LabVIEW和ModbusTCP协议,像搭积木一样连接Delta PLC 本文详细介绍了如何利用LabVIEW的图形化编程环境和ModbusTCP工业协议,快速连接Delta PLC实现数据通信。通过模块化配置和实战案例,指导读者无需编写复杂代码即可完成寄存器读取、多数据类型处理及系统监控,显著提升工业自动化项目的开发效率与部署速度。 阅读详情
1.MapAction.java
Java代码
  1. package com.zx.demo.action;   
  2.   
  3. import java.util.ArrayList;   
  4. import java.util.HashMap;   
  5. import java.util.List;   
  6. import java.util.Map;   
  7.   
  8. import com.opensymphony.xwork2.ActionSupport;   
  9. import com.zx.demo.model.Product;   
  10. import com.zx.demo.model.Student;   
  11.   
  12. public class MapAction extends ActionSupport   
  13. {   
  14.   
  15.     private Map<String,String> map;   
  16.       
  17.     private Map<String,Student> studentMap;   
  18.        
  19.     private Map<String,String[]> arrayMap;   
  20.        
  21.     private Map<String,List<Student>> listMap;   
  22.        
  23.   
  24.   
  25.     public String testMap()   
  26.      {   
  27.          map=new HashMap<String,String>();   
  28.          map.put("1", "one");   
  29.          map.put("2", "two");   
  30.            
  31.          studentMap=new HashMap<String,Student>();   
  32.          studentMap.put("student1",new Student(new Long(1),"20034140201","张三1","男",25));   
  33.          studentMap.put("student2",new Student(new Long(2),"20034140202","张三2","女",26));   
  34.          studentMap.put("student3",new Student(new Long(3),"20034140202","张三3","男",27));   
  35.            
  36.          arrayMap=new HashMap<String,String[]>();   
  37.          arrayMap.put("arr1", new String[]{"1","2003401","leejie","male","20"});   
  38.          arrayMap.put("arr2", new String[]{"2","2003402","huanglie","male","25"});   
  39.          arrayMap.put("arr3", new String[]{"3","2003403","lixiaoning","male","21"});   
  40.            
  41.            
  42.            
  43.          listMap=new HashMap<String,List<Student>>();   
  44.            
  45.          List<Student> list1=new ArrayList<Student>();   
  46.          list1.add(new Student(new Long(1),"20034140201","张三1","男",25));   
  47.          list1.add(new Student(new Long(2),"20034140202","张三2","男",25));   
  48.          list1.add(new Student(new Long(3),"20034140203","张三3","男",25));   
  49.          listMap.put("class1", list1);   
  50.            
  51.          List<Student> list2=new ArrayList<Student>();   
  52.          list2.add(new Student(new Long(1),"20034140301","李四1","男",20));   
  53.          list2.add(new Student(new Long(2),"20034140302","李四2","男",21));   
  54.          list2.add(new Student(new Long(3),"20034140303","李四3","男",22));   
  55.          list2.add(new Student(new Long(4),"20034140304","李四4","男",23));   
  56.          listMap.put("class2", list2);   
  57.             
  58.            
  59.            
  60.            
  61.         return SUCCESS;   
  62.            
  63.      }   
  64.   
  65.        
  66.        
  67.     public Map<String, String> getMap() {   
  68.         return map;   
  69.      }   
  70.   
  71.     public void setMap(Map<String, String> map) {   
  72.         this.map = map;   
  73.      }   
  74.        
  75.     public Map<String, Student> getStudentMap() {   
  76.         return studentMap;   
  77.      }   
  78.   
  79.     public void setStudentMap(Map<String, Student> studentMap) {   
  80.         this.studentMap = studentMap;   
  81.      }   
  82.   
  83.   
  84.     public Map<String, String[]> getArrayMap() {   
  85.         return arrayMap;   
  86.      }   
  87.   
  88.   
  89.     public void setArrayMap(Map<String, String[]> arrayMap) {   
  90.         this.arrayMap = arrayMap;   
  91.      }   
  92.   
  93.   
  94.   
  95.     public Map<String, List<Student>> getListMap() {   
  96.         return listMap;   
  97.      }   
  98.   
  99.   
  100.   
  101.     public void setListMap(Map<String, List<Student>> listMap) {   
  102.         this.listMap = listMap;   
  103.      }   
  104.        
  105.        
  106. }  
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代码 复制代码
  1. <%@ page contentType="text/html;charset=UTF-8" %>   
  2. <%@ taglib prefix="s" uri="/struts-tags" %>   
  3. <html>   
  4. <head>   
  5. <title>struts2中的map遍历总结</title>   
  6. </head>   
  7. <body>   
  8.     <b>1.map中的value为String字符串</b><br>   
  9.     <s:iterator value="map" id="column">   
  10.     <s:property value="#column"/><br>   
  11.     key: <s:property value="key"/><br>   
  12.     value:<s:property value="value"/><br>   
  13.     ******************************************<br>   
  14.    </s:iterator>   
  15.   
  16.   
  17.    <b>2.map中的value为Student对象</b>   
  18.    <table border="1" width="50%"   cellspacing="0" cellpadding="0">   
  19.      <tr>   
  20.        <td>key=value</td>   
  21.        <td>ID</td>   
  22.        <td>num</td>   
  23.        <td>name</td>   
  24.        <td>sex</td>   
  25.        <td>age</td>   
  26.      </tr>   
  27.      <s:iterator value="studentMap" id="column">   
  28.      <tr>   
  29.       <td><s:property value="#column"/></td>   
  30.       <td><s:property value="value.id"/></td>   
  31.       <td><s:property value="value.num"/></td>   
  32.       <td><s:property value="value.name"/></td>   
  33.       <td><s:property value="value.sex"/></td>   
  34.       <td><s:property value="value.age"/></td>   
  35.      </tr>   
  36.      </s:iterator>   
  37.    </table>   
  38.    <p>   
  39.      
  40.      
  41.    <b>3.map中的value为String数组</b>   
  42.    <table border="1" width="50%"   cellspacing="0" cellpadding="0">   
  43.      <tr>   
  44.        <td>key=value</td>   
  45.        <td>ID</td>   
  46.        <td>num</td>   
  47.        <td>name</td>   
  48.        <td>sex</td>   
  49.        <td>age</td>   
  50.      </tr>   
  51.      <s:iterator value="arrayMap" id="column">   
  52.      <tr>   
  53.       <td><s:property value="#column"/></td>   
  54.       <td><s:property value="value[0]"/></td>   
  55.       <td><s:property value="value[1]"/></td>   
  56.       <td><s:property value="value[2]"/></td>   
  57.       <td><s:property value="value[3]"/></td>   
  58.       <td><s:property value="value[4]"/></td>   
  59.      </tr>   
  60.      </s:iterator>   
  61.    </table>   
  62.    <p>   
  63.    <b>4.map中的value为list集合</b>   
  64.    <table border="1" width="50%"   cellspacing="0" cellpadding="0">   
  65.      <tr>   
  66.        <td>class</td>   
  67.        <td>ID</td>   
  68.        <td>num</td>   
  69.        <td>name</td>   
  70.        <td>sex</td>   
  71.        <td>age</td>   
  72.      </tr>   
  73.        
  74.     <s:iterator value="listMap" id="column">   
  75.       <s:set name="total" value="#column.value.size"/>   
  76.       <s:iterator value="#column.value" status="s">   
  77.        <tr>   
  78.          <s:if test="#s.first"><td rowspan="${total}"><s:property value="#column.key"/></td></s:if>   
  79.          <td><s:property value="id"/></td>   
  80.          <td><s:property value="num"/></td>   
  81.          <td><s:property value="name"/></td>   
  82.          <td><s:property value="sex"/></td>   
  83.          <td><s:property value="age"/></td>   
  84.        </tr>   
  85.       </s:iterator>   
  86.    </s:iterator>   
  87. </table>   
  88.      
  89.      
  90. </body>   
  91. </html>  
极速建站!用1Panel面板一键部署Halo博客的保姆级教程 | 企业官网/个人博客搭建教程 个人博客是一种在互联网上发布自己的文章、图片、视频等内容的平台,通常以文字为主要形式,但也可以包含其他媒体。个人博客的用途非常广泛。它可以用来记录博主的日常生活、分享自己的知识和经验、展示自己的作品和技能,以及交流自己的观点和看法。通过个人博客,博主可以与读者建立联系,分享自己的见解和体验,同时也可以从读者那里获得反馈和建议。 阅读详情

相关推荐

autodl云服务器使用中的conda源报错

通过find path -name filename找到.condarc文件,在autodl服务器中,一般在/root/.condarc。为了利用jypyter打开conda虚拟环境运行,需要下载ipykenel。这个报错是源的问题,在通过源获取包元数据时出现了HTTP 429错误。通过conda换源解决。修改.condarc文件,命令: vim .condarc。但这样还不能解决问题,得把报错中有问题的源注释掉。通过以下命令添加清华镜像源。把报错的链接源注释如下。

Ty_kilig的博客 1584

s标签显示后台数据的基本用法以及iterator遍历用法

普通属性 java文件赋值并且set和get private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = usern

直到世界的尽头 6721

解决linux 2.5G网卡驱动问题

解决linux 2.5G网卡驱动问题 关键词:2.5G网卡驱动,ubuntu,安装,2.5G Ethernet LINUX driver,Realtek网卡驱动 由于2.5G网卡较新,各linux发行版的通用驱动已不适用,新装的系统会出现无法上网问题,由于国内网络环境去Realtek官网很难下载到驱动文件,故本文提供github上的2.5G Ethernet LINUX driver r8125 for kernel up to 5.6的版本驱动文件r8125-9.003.05.tar.bz2各位可以自

poorguy_aos的博客 1万+

迭代器iterator遍历集合

集合分为list、set和map。list排列有序,可重复;set排列无序,不可重复;map键不可重复,值可重复,排列无序。 一般遍历用for循环,但是set和map无序,所以要用迭代器。 迭代器是将数据放在一个容器中,并排成一排,迭代器有一个游标,再未遍历之前,这个游标放在第一位元素的前面,一般是迭代器iterator.hasNext判断游标后面是否有元素,iterator.next是将游标向后移一位。 list集合分为ArrayList、vector、LinkedList ArrayList:排列有序,

m0_46287385的博客 1万+

Wordpress实战之第二章安装wordpress 软件需要的软件

使用下载并安装phpstudy面版工具 wget -O install.sh?https://notdocker.xp.cn/install.sh?&& sudo bash install.sh 2.安装成功如下 ==============运行状态========================= webpanel stop phpstudy running =================...

安全参透之旅 612

【EPICS学习记录】根据官方教程创建一个IOC应用

参照官网给出的IOC创建教程逐步操作完成了一个IOC应用的创建,官网教程中有部分过程表述的不清晰,自己摸索之后完成了IOC的创建,并把流程记录下来。其中有一些操作不是很理解,有问题或者建议欢迎指正。

yifeng_H的博客 3661

struts2标签iterator迭代器遍历List集合常用例子

【摘要】本文主要介绍及演示了Struts迭代器(iterator)遍历List常用的4种例子,基于MyEclipse开发环境,重点关注前后端代码的实现,给出后端java代码、前段struts标签代码,主要有如下4个例子: 1.&nbsp;遍历List&lt;String&gt; 2.&nbsp;遍历List&lt;List...

Onely丶初 2189

QNX系统中的密码哈希格式——数据安全深度分析

综上所述,QNX系统中的Shadowed密码哈希格式提供了一种有效的数据安全机制,能够保护用户密码的安全性。通过将用户密码的哈希值存储在系统文件中,并结合哈希算法和盐值的使用,可以有效地防止明文密码泄露和密码破解。密码哈希是一种常用的安全技术,用于将用户密码转换为不可逆的哈希值,以保护用户的敏感信息。在QNX操作系统中,存在一种称为Shadowed密码哈希格式的机制,用于存储用户密码的安全散列值。当用户登录系统时,系统会将用户输入的密码与保存的哈希值进行比对,以验证密码的正确性。在上述代码中,首先使用。

UneDatabase的博客 252

iterator 标签 详解及双重循环List

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33815613的博客 955

华为自研 ERP、Oracle EBS 与 SAP 上线时系统配置思路设计差异深度分析

本文对比分析了华为自研ERP、Oracle EBS和SAP S/4HANA三大ERP系统在上线配置思路上的核心差异。从架构设计看,华为采用分布式微服务架构,SAP采用分层服务架构,Oracle采用集中式一体化架构;在模块配置上,华为以业务场景为导向,SAP基于行业模板,Oracle强调模块独立性;数据迁移方面,华为侧重业务规则清洗,SAP注重数据质量监控,Oracle依赖标准化工具;流程适配上,华为系统随流程调整,SAP在框架内优化,Oracle需定制开发;定制开发模式差异明显,华为采用插件化扩展,SAP使

金牌架构师 1454

从0开始图形学(光栅化)

从0开始图形学

A112459的专栏 2395

Struts 2中<s:append>标签的用法

0.建立项目建立项目并使用myeclipse自带的工具配置Struts 2。我的项目名为Ex31.编写下面的append.jsp页面使用append标签合并两个param的集合,然后使用iterator标签遍历append中的内容<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib uri="/

并非所有流浪者都迷失了自我 1640

【ROS2】手眼标定:moveit2_handeye_calib使用详解

moveit2_handeye_calib MoveIt2 官方的 手眼标定功能包,包含标定插件、图形化界面和示例程序。提供基于 ArUco/ChArUco 标定板的采集与求解功能。标定板下载aruco在线生成器。

郭老二 248

Struts 2中<s:iterator>标签的用法

0.建立项目建立项目并使用myeclipse自带的工具配置Struts 2。我的项目名为Ex31.编写下面的iterator.jsp页面<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib uri="/struts-tags" prefix="s" %> <!DOCTYPE HTML PUBLI

并非所有流浪者都迷失了自我 406

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Struts遍历标签s:iterator总结

struts2的s:iterator可以遍历 数据栈里面的任何数组,集合等等 以下几个简单的demo: s:iterator 标签有3个属性: value被迭代的集合 id集合里面的元素的id,可以和var属性替换 status迭代元素的索引 1:jsp页面定义元素写法数组或...

chuoqi9242的博客 139

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Struts2的常用通用标签库

set往值栈里面传入数据 if进行判断 &lt;s:set var="i" value="3" scope="request"&gt;&lt;/s:set&gt; &lt;s:if test="#request.i&gt;3"&gt; i&gt;3 &lt;/s:if&gt; &lt;s:elseif test="#request

weixin_40007271的博客 245

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

struts2标签库使用

用过struts1.x的人都知道,标签库有html、bean、logic、tiles,而struts2.0里的标签却没有分类,只用在jsp头文件加上    就能使用struts2.0的标签库  A:  -----超链接,类似于html里的  -----执行一个view里面的一个action  -----如果action的errors有值那么显示出来  -----如果ac

tutuxiaobudian的专栏 461

struts2标签

A:   s:a xhref="">s:a>-----超链接,类似于html里的a>a>   s:action name="">s:action>-----执行一个view里面的一个action   s:actionerror/>-----如果action的errors有值那么显示出来   s:actionmessage/>-----如果action的message有值那么显示出来  

u013948187的专栏 443

struts2标签大全

用过struts1.x的人都知道,标签库有html、bean、logic、tiles, 而struts2.0里的标签却没有分类,只用在jsp头文件加上 就能使用struts2.0的标签库 下面就介绍下每个标签的用法(有错请指正): A: -----超链接,类似于html里的 -----执行一个view里面的一个action -----如果action的errors有值那么

waj89757的专栏 1028

Struts2---Struts-Tags

1.通用标签 >property >set       >bean >include >param >debug property标签 property-name: property-String: property-age: property-default: property-escape:'" escape="false"

白夜行 1029

Struts2 按字母排序标签库

 用过struts1.x的人都知道,标签库有html、bean、logic、tiles,而struts2.0里的标签却没有分类,只用在jsp头文件加上就能使用struts2.0的标签库下面就介绍下每个标签的用法(有错请指正):A:-----超链接,类似于html里的-----执行一个view里面的一个action-----如果action的errors有值那

hoojo 1684

struts2.0 标签库

就能使用struts2.0的标签库 下面就介绍下每个标签的用法(有错请指正): A:-----超链接,类似于html里的 -----执行一个view里面的一个action -----如果action的errors有值那么显示出来 -----如果action的message有值那么显示出来 -----添加一个值到list,类似于list.add(); -----自动完成标签...

iteye_14171的博客 171

struts2 标签

&lt;%@ taglib prefix="s" uri="/struts-tags" %&gt; 一条 &lt;s:property value='CLSP' /&gt; if语句 &lt;s:if test="CLSP==true "&gt; &lt;/s:if&gt; &lt;s:ifelse test="VIsNew==2 &amp

mmmzzc的专栏 112

Struts2 控制 标签 之 append

struts.xml    /pages/genericTags/AppendTag.jsp Create two lists in the action class and populate them with various items as shown in the  "AppendTag" class AppendTag.javapackage net.ro

getdate的专栏 2017

struts2 标签学习

用过struts1.x的人都知道,标签库有html、bean、logic、tiles,而struts2.0里的标签却没有分类,只用在jsp头文件加上&lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;就能使用struts2.0的标签库 下面就介绍下每个标签的用法(有错请指正): A: &lt;s:a href=""&gt;&lt;/s:a&gt;..

topMan'blog 76

常用的Struts 2.0的标志(Tag)介绍

在上一篇文章《为Struts 2.0做好准备》中,我过于详细地介绍了Struts 2.0开发环境和运行环境的配置,所以,本文很少涉及的以上两方面的细节。如果,您看完《为Struts 2.0做好准备》后,还有什么不明白,或者没法运行文中例子,请联系我。我的E-MAIL:Max.M.Yuan@gmail.com。 在介绍常用标志前,我想先从总体上,对Struts 1.x与Struts 2.0的标志库(...

panzhiwei 90
上一篇: Struts2操作Request、Session和App…
下一篇: struts2中struts.xml什么时候加载…
jarry.liu
博客等级 码龄16年 36粉丝 304原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值