zoukankan      html  css  js  c++  java
  • 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;
     }

  • 相关阅读:
    .net core EF 入门笔记Code First
    Windows环境下安装MongodDB
    Ueditor1.4.3.3 富文本编辑器在图片不显示问题
    .net IIS网站部署Host文件简单应用
    .Net初学Less的安装与部署
    EF+MVC动态Lamda表达式拼接(学习笔记二)
    EF+MVC动态Lamda表达式拼接(学习笔记)
    区块链从入门到放弃
    Unity3D的update和FixedUpdate
    忽雷太极拳十三式
  • 原文地址:https://www.cnblogs.com/zfswff/p/3502505.html
Copyright © 2011-2022 走看看