• <tfoot id='a01yk'></tfoot>
      <bdo id='a01yk'></bdo><ul id='a01yk'></ul>
    <legend id='a01yk'><style id='a01yk'><dir id='a01yk'><q id='a01yk'></q></dir></style></legend>

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

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

        如何在struts2中仅获取特定字段作为响应

        how to get only particular fields in response in struts2(如何在struts2中仅获取特定字段作为响应)

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

              <tfoot id='pJATg'></tfoot>
                <tbody id='pJATg'></tbody>
            • <legend id='pJATg'><style id='pJATg'><dir id='pJATg'><q id='pJATg'></q></dir></style></legend>

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

                <i id='pJATg'><tr id='pJATg'><dt id='pJATg'><q id='pJATg'><span id='pJATg'><b id='pJATg'><form id='pJATg'><ins id='pJATg'></ins><ul id='pJATg'></ul><sub id='pJATg'></sub></form><legend id='pJATg'></legend><bdo id='pJATg'><pre id='pJATg'><center id='pJATg'></center></pre></bdo></b><th id='pJATg'></th></span></q></dt></tr></i><div id='pJATg'><tfoot id='pJATg'></tfoot><dl id='pJATg'><fieldset id='pJATg'></fieldset></dl></div>
                • 本文介绍了如何在struts2中仅获取特定字段作为响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个动作类,其中定义了许多动作方法,并且还定义了适当的 getter 和 setter 方法.我有一些操作方法,我通过从 jQuery 调用它们来获取 json 格式的数据.但是当我获得 json 数据时,它包括定义了 getter 和 setter 的所有字段,但我只想获取由我正在调用的方法填充的字段.例如-

                  I have an action class in which many action methods are defined and appropriate getters and setters methods are also defined. I have some action methods from which I get the data as json by calling them from jQuery. but when I get the json data it includes all the fields for which getters and setters are defined but i want to get only that field which is filled by that method to which i am calling. for example-

                  public class ApplicantRegistration extends ActionSupport{
                  private String s1;
                  private XyzBean bean;
                  private String s2;
                  // respective getters and setters....
                  
                  public String m1(){
                  // some work
                   return SUCCESS;
                  }
                  
                  public String m2(){
                     //some work
                      s2="abc";
                      return SUCCESS;
                  }
                  
                  
                  }
                  

                  当我通过 jQuery 调用方法 m2 并获得 json 响应时,它给出了

                  when i call method m2 via jQuery and get json response it gives

                  {
                   s1: null,
                   bean: null,
                   s2:"abc",
                   m2: "success",
                  
                  }
                  

                  但我只想要

                  {
                   s2:"abc"
                  }
                  

                  推荐答案

                  默认 json result 序列化 root 参数指定的所有 bean 属性,默认设置为那个行动.但是您可以使用结果的 includeProperties 参数来仅过滤 root 中与正则表达式匹配的那些属性.

                  By default json result serializes all bean properties specified by the root parameter which is set by default to the action. But you can use includeProperties parameter of the result to filter only those properties from the root that matched regex expressions.

                  @Result(type="json", params = {"includeProperties", "^s2"})
                  

                  这篇关于如何在struts2中仅获取特定字段作为响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                      <bdo id='ytIgv'></bdo><ul id='ytIgv'></ul>
                      <i id='ytIgv'><tr id='ytIgv'><dt id='ytIgv'><q id='ytIgv'><span id='ytIgv'><b id='ytIgv'><form id='ytIgv'><ins id='ytIgv'></ins><ul id='ytIgv'></ul><sub id='ytIgv'></sub></form><legend id='ytIgv'></legend><bdo id='ytIgv'><pre id='ytIgv'><center id='ytIgv'></center></pre></bdo></b><th id='ytIgv'></th></span></q></dt></tr></i><div id='ytIgv'><tfoot id='ytIgv'></tfoot><dl id='ytIgv'><fieldset id='ytIgv'></fieldset></dl></div>
                    • <tfoot id='ytIgv'></tfoot>

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

                      <legend id='ytIgv'><style id='ytIgv'><dir id='ytIgv'><q id='ytIgv'></q></dir></style></legend>
                              <tbody id='ytIgv'></tbody>