Hi,
I’m not an expert with the internals of the REST plugin, but am using it fairly
extensively. By and large we use annotations in our classes to determine
results (see org.apache.struts2.convention.annotation.Results) but it is
certainly possible to define some globals and it is definitely possible to
configure interceptors. Given that a picture is worth a thousand words, here is
a snippet from our struts XML:
<constant name="struts.convention.default.parent.package"
value="globalPackage"/>
<package name="globalPackage" extends="rest-default"> <result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types> <interceptors> <interceptor
name="setReturnURL" class="com.xyz.webapp.interceptors.ReturnURLInterceptor"/>
<interceptor name="categoryInterceptor"
class="com.xyz.webapp.interceptors.CategoryInterceptor"/>
<interceptor-stack name="restDefaultInterceptors"> <interceptor-ref
name="restDefaultStack"/> <interceptor-ref
name="setReturnURL"/> <interceptor-ref name="categoryInterceptor"/>
</interceptor-stack> </interceptors> <default-interceptor-ref
name="restDefaultInterceptors"/> <global-results> <result
name="login" type="redirectAction"> <param
name="actionName">login</param> <param
name="namespace">/site</param> </result> </global-results>
</package>
So you can see that our main package (globalPackage) is defined such that it
extends rest-default. We then create a new interceptor stack and specify that
as the default interceptor for the package. Finally, and perhaps most
importantly, we ensure that the constant
“struts.convention.default.parent.package” points to our globalPackage.
Hope that helps you
Regards
Stuart
On 28/05/2009 02:12, "xnpeng" <[email protected]> wrote:
can any one help? i use struts2.1.6.
在2009-05-20,xnpeng <[email protected]> 写道:
>I'm doing my project with struts2+rest-plugin for about 3 months.there is a
>lot of problems unresolved.
>
>With rest-plugin and convention-plugin,all action-mapping are done
>automatically,manual action-mapping in struts.xml cannot work.so,
>1, I cannot define global-error-result;
>2, I cannot do forward;
>3, I cannot insert my own Interceptors.
>
>I 'm watching this mail-list day and day, there is not much discuss on
>rest-plugin, neithere is enough materials on the internet. Does someone have
>much experience on this topic? I need your help ergently!
>
>
>