5

申し訳ありませんが、この質問のタイトルを要約する方法が本当にわかりません。そのため、タイトルがわかりにくいかもしれません。

ビジネスロジックを実行するアクションクラスがあります。

アクションクラスで:

class ActionClass extends ActionSupport{
      private Merchandise merchandise;// I want to transfer it to the client
      //setter and getter

}

商品クラス:

class Merchandise{
    private String name; // I want to transfer it
    private String price; //I don't want to transfer it
    private String description;//I don't want to transfer it
    //setter and getter
}

ここで、ActionClassの商品プロパティをクライアントに転送する必要があります。

ただし、商品プロパティでは、名前プロパティのみを転送し、他の 2 つのプロパティを禁止したいと考えています。

次に、Merchandise クラスの他の 2 つのプロパティ (価格と説明) の転送を禁止する方法は?

4

3 に答える 3

5

次のようなものを試してください:

<!-- Result fragment -->
<result type="json">
  <param name="root">merchandise</param>
  <param name="excludeProperties">price,description</param>
</result>

http://struts.apache.org/2.2.3/docs/json-plugin.htmlで完全なドキュメント、その他のオプション、および例を参照してください。

于 2011-08-03T11:53:22.047 に答える
0

最も簡単な方法は、クライアントに送信するフィールドのみを含むデータ転送オブジェクトをアクションクラスに作成し、それをルートオブジェクトにすることです。

于 2013-03-05T07:26:41.280 に答える