1. 程式人生 > >struts2 傳遞陣列、List、Map

struts2 傳遞陣列、List、Map

jsp檔案

陣列:
     <s:textfield name="ages" value="a1"></s:textfield>
     <s:textfield name="ages" value="a2"></s:textfield>
     <s:textfield name="ages" value="a3"></s:textfield>
     
     <s:textfield name="names[0]" value="n1"></s:textfield>
     <s:textfield name="names[1]" value="n2"></s:textfield>
     <s:textfield name="names[2]" value="n3"></s:textfield>
  List:
     <s:textfield name="lastName[0]" value="11"></s:textfield>
     <s:textfield name="lastName[1]" value="21"></s:textfield>
     <s:textfield name="lastName[2]" value="31"></s:textfield>
     
  Map
     <s:textfield name="maid.mary"></s:textfield>
     <s:textfield name="maid['beth']"></s:textfield>

java檔案

System.out.println(ages.toString()+names.toString()+getLastName().toString());
     
  Map map = getMaid();

System.out.println(map.get("mary")+":"+map.get("beth"));

/*陣列*/
 private String[] ages;
 

 /**
  * @return the ages
  */
 public String[] getAges() {
  return ages;
 }

 /**
  * @param ages the ages to set
  */
 public void setAges(String[] ages) {
  this.ages = ages;
 }
 
 private String[] names = new String[10];

 /**
  * @return the names
  */
 public String[] getNames() {
  return names;
 }

 /**
  * @param names the names to set
  */
 public void setNames(String[] names) {
  this.names = names;
 }
 
 private List<Integer> lastName;

 /**
  * @return the lastName
  */
 public List<Integer> getLastName() {
  return lastName;
 }

 /**
  * @param lastName the lastName to set
  */
 public void setLastName(List<Integer> lastName) {
  this.lastName = lastName;
 }
 
 private Map maid;

 /**
  * @return the maid
  */
 public Map getMaid() {
  return maid;
 }

 /**
  * @param maid the maid to set
  */
 public void setMaid(Map maid) {
  this.maid = maid;
 }

相關推薦

struts2 傳遞陣列ListMap

jsp檔案 陣列:     <s:textfield name="ages" value="a1"></s:textfield>     <s:textfield name="ages" value="a2"></s:textfie

Struts2的OGNL遍歷陣列List簡單的Map

一、簡介 <s:iterator />可以遍歷資料棧裡面的任何陣列,集合等等 在使用這個標籤的時候有三個屬性值得我們關注1. value屬性:可選的屬性,value屬性是指一個被迭代的集合,使用ognl表示式指定,如果為空的話預設就是ValueStack棧頂的集合. 2.id屬性:可選屬性, 是

FastJson 陣列ListSetMap基本序列化與日期格式化

摘要: FastJson可以直接序列化陣列、List、Set、Map等,也可以直接支援日期型別資料的格式化,包括java.util.Date、java.sql.Date、java.sql.Timestamp、java.sql.Time。   FastJson不僅可以支援普通

Spring中使用MapSetList陣列屬性集合的注入方法配置檔案

(1)下邊的一個java類包含了所有Map、Set、List、陣列、屬性集合等這些容器,主要用於演示Spring的注入配置; package com.lc.collection; import java.util.List; import java.util.Map;

java beanList陣列map和Json的相互轉化

package com.my.json; import java.util.ArrayList; import java.util.List; import java.util.Map; import net.sf.json.JSONArray; import net.sf.json.J

Ognl訪問陣列ListMap

陣列 package com.xs; import ognl.Ognl; import ognl.OgnlContext; import ognl.OgnlException; public class OgnlAarray { /** * @param ar

Java 集合轉換(陣列ListSetMap相互轉換)

package com.example.test; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; impo

Java 集合轉換(Object[]陣列ListSetMap相互轉換)

package com.example.test; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; impo

Java 遍歷Map ListSet陣列的方法

List<String> list = new ArrayList<String>(); list.add("aaa"); list.add("bbb"); list.add("ccc"); 方法一: 超級for迴圈遍歷 for(String attribute : list) {

Spring中使用MapSetList數組屬性集合的註入方法配置文件

查看 main list highlight 配置 spring配置 pla lec while (1)下邊的一個Java類包含了所有Map、Set、List、數組、屬性集合等這些容器,主要用於演示spring的註入配置; [java] view plain c

java並發容器(MapListBlockingQueue)具體解釋

current 兩種 避免 由於 新的 rom 就會 family err Java庫本身就有多種線程安全的容器和同步工具,當中同步容器包含兩部分:一個是Vector和Hashtable。另外還有JDK1.2中增加的同步包裝類。這些類都是由Collections.s

MapListSet在Java中的各種遍歷方法

try one out 循環 java light size i++ pre 一、Map的4種遍歷 Map<String, String> map = new HashMap<String, String>(); map.put("姓名", "

【redis,1】java操作redis: 將stringlistmap自己定義的對象保存到redis中

n) spa 存儲 div ber sys mil 操作 write 一、操作string 、list 、map 對象 1、引入jar: jedis-2.1.0.jar 2、代碼 /

Java中集合類setListmap的遍歷方式

Java中集合類的遍歷方式 Java中集合分為set、List和map。 1.set集合 set集合常用的有兩種遍歷方式: Set<String>  set = new HashSet<String>(); 第一種利用for迴圈: for(S

C++常用的容器(vectorsetlistmap

C++ STL中最基本以及最常用的類或容器無非就是以下幾個: string vector set list map 下面就依次介紹它們,並給出一些最常見的最實用的使用方法,做到快速入門。 string 首先看看我們C語言一般怎麼使用字串的 c

【小家java】Java之Apache Commons-Collections4使用精講(含有BagMapListSet全覆蓋)

相關閱讀 【小家java】java5新特性(簡述十大新特性) 重要一躍 【小家java】java6新特性(簡述十大新特性) 雞肋升級 【小家java】java7新特性(簡述八大新特性) 不溫不火 【小家java】java8新特性(簡述十大新特性) 飽受讚譽 【小家java】java9

轉:Java集合類: SetListMapQueue使用場景梳理

轉自:https://www.cnblogs.com/LittleHann/p/3690187.html   本文主要關注Java程式設計中涉及到的各種集合類,以及它們的使用場景   相關學習資料 http://files.cnblogs.com/Little

陣列listarraylist三者的區別

原地址(http://www.cnblogs.com/a164266729/p/4561651.html) 陣列、List和ArrayList的區別   陣列在記憶體中是連續儲存的,所以它的索引速度是非常的快,而且賦值與修改元素也很簡單,比如: string[] s=new string

Java集合概述SetListMap

Java的集合類是由兩個介面類派生而出:Collection、Map 1、Collection介面派生出來的Set集合是無序集合,派生出的List集合是有序集合、佇列Queue -Set集合中的元素無序不允許重複 -List集合類似陣列,元素有序同時長度可變,且元素允許重複

MAPSETLISTQUEUESTACK的特點與用法

這裡是修真院後端小課堂,每篇分享文從 【背景介紹】【知識剖析】【常見問題】【解決方案】【編碼實戰】【擴充套件思考】【更多討論】【參考文獻】 八個方面深度解析後端知識/技能,本篇分享的是: 【MAP、SET、LIST、QUEUE、STACK的特點與用法】 1.背景介紹 MAP