• 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;
     }

  • 相关阅读:
    VS2010调用外部webservice
    VS2013如何调用别人发布的WebService程序
    VS2010 根据WSDL文件(java Web Service)生成.cs文件
    vs2010 创建和发布 webservice
    CXF+Spring+Tomcat 案例
    LDAP方式连接AD获取用户信息
    webService和RMI
    当spring抛出异常时出现的页面的@ExceptionHandler(RuntimeException.class) 用法
    eclips中maven解决jsp报错的问题
    用idea搭建一个简单的SSM的Demo
  • 原文地址:https://www.cnblogs.com/zfswff/p/3502505.html
Copyright © 2020-2023  润新知