• <i id='C9jJn'><tr id='C9jJn'><dt id='C9jJn'><q id='C9jJn'><span id='C9jJn'><b id='C9jJn'><form id='C9jJn'><ins id='C9jJn'></ins><ul id='C9jJn'></ul><sub id='C9jJn'></sub></form><legend id='C9jJn'></legend><bdo id='C9jJn'><pre id='C9jJn'><center id='C9jJn'></center></pre></bdo></b><th id='C9jJn'></th></span></q></dt></tr></i><div id='C9jJn'><tfoot id='C9jJn'></tfoot><dl id='C9jJn'><fieldset id='C9jJn'></fieldset></dl></div>

    <small id='C9jJn'></small><noframes id='C9jJn'>

      • <bdo id='C9jJn'></bdo><ul id='C9jJn'></ul>
      1. <legend id='C9jJn'><style id='C9jJn'><dir id='C9jJn'><q id='C9jJn'></q></dir></style></legend>

        <tfoot id='C9jJn'></tfoot>

      2. 将序列化数组传递给 struts2 动作

        Passing serialize array to struts2 action(将序列化数组传递给 struts2 动作)
          <tbody id='ybqGR'></tbody>
          <bdo id='ybqGR'></bdo><ul id='ybqGR'></ul>

            <small id='ybqGR'></small><noframes id='ybqGR'>

                • <i id='ybqGR'><tr id='ybqGR'><dt id='ybqGR'><q id='ybqGR'><span id='ybqGR'><b id='ybqGR'><form id='ybqGR'><ins id='ybqGR'></ins><ul id='ybqGR'></ul><sub id='ybqGR'></sub></form><legend id='ybqGR'></legend><bdo id='ybqGR'><pre id='ybqGR'><center id='ybqGR'></center></pre></bdo></b><th id='ybqGR'></th></span></q></dt></tr></i><div id='ybqGR'><tfoot id='ybqGR'></tfoot><dl id='ybqGR'><fieldset id='ybqGR'></fieldset></dl></div>
                • <tfoot id='ybqGR'></tfoot><legend id='ybqGR'><style id='ybqGR'><dir id='ybqGR'><q id='ybqGR'></q></dir></style></legend>

                  本文介绍了将序列化数组传递给 struts2 动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我打算将整个表单数据以 JSON 格式发布到 Struts2 Action.下面是我的代码片段.纠正我哪里出错或帮助我,以便我可以正确获取操作文件中的所有值.我的所有操作文件中的 SOP 都显示为 null

                  I am planning to post entire form data in JSON format to Struts2 Action. Below are my code snippets. Correct me where I am going wrong or Help me so that I can get all values in the Action file correctly. All of my SOPs in Action file is displayed as null

                  var MyForm = $("#companyform").serializeArray();
                     var data = JSON.stringify(MyForm);
                  
                  
                     $.ajax({
                         type: 'POST',
                         url:'createcompany.action?jsonRequestdata='+data,
                         dataType: 'json',
                         success: function(data){
                               console.log(stringify(data));
                          }});
                  

                  我的表单数据变成[{"name":"tan","value":"rrr"},{"name":"pan","value":"adf"},{"name":"tod","value":"1"}]

                  Struts2 动作文件:

                  String jsonRequestdata;
                  public String execute() throws Exception {
                      JSONArray jsonArr = (JSONArray) new JSONParser().parse(jsonRequestdata);
                      JSONObject json = (JSONObject) jsonArr.get(0);
                  
                  
                      System.out.println("TAN=" + json.get("tan"));
                      System.out.println("PAN=" + json.get("pan"));
                      System.out.println("TOD=" + json.get("tod"));
                      return "success";
                  }
                  

                  当前输出

                  TAN=null
                  PAN=null
                  TOD=null
                  

                  推荐答案

                  由于我使用的是name,value我必须使用name来获取它.下面是工作代码

                  Since I am using name,value I must get it by using name. Below is the working code

                  JSONArray jsonArr = (JSONArray) new JSONParser().parse(jsonRequestdata);
                  
                      for(int i=0;i<jsonArr.size();i++){
                              JSONObject json=(JSONObject) jsonArr.get(i);   
                              System.out.println("name=" + json.get("name"));
                              System.out.println("value=" + json.get("value"));
                      }
                  

                  这篇关于将序列化数组传递给 struts2 动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)

                  1. <small id='Rj39Z'></small><noframes id='Rj39Z'>

                        <tfoot id='Rj39Z'></tfoot>
                          <tbody id='Rj39Z'></tbody>
                          <bdo id='Rj39Z'></bdo><ul id='Rj39Z'></ul>
                          <i id='Rj39Z'><tr id='Rj39Z'><dt id='Rj39Z'><q id='Rj39Z'><span id='Rj39Z'><b id='Rj39Z'><form id='Rj39Z'><ins id='Rj39Z'></ins><ul id='Rj39Z'></ul><sub id='Rj39Z'></sub></form><legend id='Rj39Z'></legend><bdo id='Rj39Z'><pre id='Rj39Z'><center id='Rj39Z'></center></pre></bdo></b><th id='Rj39Z'></th></span></q></dt></tr></i><div id='Rj39Z'><tfoot id='Rj39Z'></tfoot><dl id='Rj39Z'><fieldset id='Rj39Z'></fieldset></dl></div>
                          <legend id='Rj39Z'><style id='Rj39Z'><dir id='Rj39Z'><q id='Rj39Z'></q></dir></style></legend>