0

I have this exact same line in 5 places in my struts xml -

<result name="error" type="json"><param name="root">response</param></result>

Is there a way i can declare this as some sort of custom result and include it in the 5 places i'm using it?

4

1 に答える 1

1

複数の場所で使用する必要はありません。代わりに、これをグローバル結果として定義してください。

<global-results>
    <result name="error" type="json">
       <param name="root">response</param>
    </result>
</global-results>

したがって、アクションがエラーを返す場合、グローバル結果からのこの結果を使用して使用します。

しかし、あなたが次のようなものが必要な場合

<action name="someaction" class="somepackage.someAction">
   <result name="error" type="json">ReferSomeOhterResult</result>
</action>

これは不可能です。チェーンして別のアクションにリダイレクトすることしかできませんが、ある結果が別の結果を参照することはできません。

于 2012-05-24T09:19:10.820 に答える