• <small id='UWMcQ'></small><noframes id='UWMcQ'>

        <bdo id='UWMcQ'></bdo><ul id='UWMcQ'></ul>

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

        Struts 2 jquery sj:select 和 json 结果

        Struts 2 jquery sj:select and json result(Struts 2 jquery sj:select 和 json 结果)
        <legend id='1NRL8'><style id='1NRL8'><dir id='1NRL8'><q id='1NRL8'></q></dir></style></legend>
          <bdo id='1NRL8'></bdo><ul id='1NRL8'></ul>
          • <i id='1NRL8'><tr id='1NRL8'><dt id='1NRL8'><q id='1NRL8'><span id='1NRL8'><b id='1NRL8'><form id='1NRL8'><ins id='1NRL8'></ins><ul id='1NRL8'></ul><sub id='1NRL8'></sub></form><legend id='1NRL8'></legend><bdo id='1NRL8'><pre id='1NRL8'><center id='1NRL8'></center></pre></bdo></b><th id='1NRL8'></th></span></q></dt></tr></i><div id='1NRL8'><tfoot id='1NRL8'></tfoot><dl id='1NRL8'><fieldset id='1NRL8'></fieldset></dl></div>

              <tbody id='1NRL8'></tbody>

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

                <tfoot id='1NRL8'></tfoot>

                  本文介绍了Struts 2 jquery sj:select 和 json 结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 struts 2 jquery 插件选择组件.

                  I am using struts 2 jquery plugin select component.

                  动作是:

                  SampleAction {
                  
                         private List<SampleVO> samples; //With setters and getters
                         private List<AnotherVO> anotherList; //With setters and getters
                         private String anString; //With setters and getters
                  
                         @Action(value = "/loadSelect", results = {
                         @Result(name = "success", type = "json")})
                               public String loadSomeSamples() {
                                  samples = new ArrayList<SampleVO>();
                                  //Put some object in samples.
                                  return SUCCESS;
                                }
                      }
                  

                  jsp是

                  <sj:select list="samples" />
                  

                  问题在于 json 插件会序列化所有正在运行的属性(anotherListanString 等...),如下所示

                  The problem is that the json plugin will serialize all the properties in action ( anotherList, anString etc...), as below

                  {
                    "samples": {
                      "0": {"property":"a"},
                      "1": {"property":"b"},
                      "2": {"property":"c"}
                    },
                    "anString": "hello",  
                    "anotherList": {
                      "0": {"prop1":"a","prop2":"b"},
                      "1": {"prop1":"c","prop2":"d"}
                    }
                  }
                  

                  如果我将 json root 参数更改为 samples,那么 js:select 将无法工作,因为它找不到任何名为返回的 json 中的 samples.返回的json是:

                  If I change the json root parameter to samples, then the js:select will not work as it can not find any list named samples in the returned json. The returned json is:

                  {
                      "0": {"property":"a"},
                      "1": {"property":"b"},
                      "2": {"property":"c"}
                  }
                  

                  这可以解决吗?!有什么办法可以配置struts 2 json插件来生成

                  Can this be fixed ?! Is there any way I can configure struts 2 json plugin to generate

                   {
                    "samples": {
                          "0": {"property":"a"},
                          "1": {"property":"b"},
                          "2": {"property":"c"}
                        }
                    }
                  

                  或者为什么struts 2 jquery插件接受简单的json数组

                  Or is there any why struts 2 jquery plugin in accept the simple json array

                  推荐答案

                  您可以使用 includeProperties 参数来获取 json 结果.例如

                  You can use includeProperties parameter to json result. For example

                  @Result(type="json", params = {"includeProperties", "samples.*" })
                  

                  再来一个样本

                  @Result(type="json", params = {"root", "samples", "wrapPrefix", "{"samples":", "wrapSuffix", "}"})
                  

                  这篇关于Struts 2 jquery sj:select 和 json 结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)
                  • <tfoot id='NtDzd'></tfoot>

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

                          • <bdo id='NtDzd'></bdo><ul id='NtDzd'></ul>