0

我在我的 struts xml 中的 5 个地方有完全相同的行 -

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

有没有办法可以将其声明为某种自定义结果并将其包含在我使用它的 5 个地方?

4

1 回答 1

1

You dont have to use it at multiple places instead define this as global result.

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

So when your action will return error it will use this result from the global result and use it.

But if you want something like

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

this is not possible, you can only chain, redirect to a different action but one result cannot refer to another result.

于 2012-05-24T09:19:10.820 回答