Using struts.xml with convention plugin

Posted by David Alt on Stack Overflow See other posts from Stack Overflow or by David Alt
Published on 2010-06-12T16:43:56Z Indexed on 2010/06/12 16:52 UTC
Read the original article Hit count: 300

Filed under:
|
|

This seems like it should be easy to do, but I just can make it work. I'm hooked on the convention plugin in Struts 2.1. However, I need to define some package-level configuration such as a new interceptor stack and exception mappings. I'd like to use the struts.xml file for this, but I can't get the convention-based packages matched to the struts.xml packages. My struts.xml looks like:

<struts>
<constant name="struts.convention.default.parent.package" value="default"/>  
<package name="default" extends="struts-default">
</package>
<package name="root" namespace="/" extends="struts-default">
    <action name="index">
        <result>/index.jsp</result>
    </action>
</package>

<package name="my.package.actions.myaccount" namespace="/myaccount" extends="struts-default">
<interceptors>
    <interceptor name="authenticationInterceptor" class="my.package.interceptors.AuthenticationInterceptor"/>
    <interceptor-stack name="secureStack">
        <interceptor-ref name="authenticationInterceptor"/>
        <interceptor-ref name="defaultStack"/>
    </interceptor-stack>
</interceptors>

    <default-interceptor-ref name="secureStack"/>
</package>
</struts>

I have my interceptor in:
/src/my/package/interceptors
and my actions in:
/src/my/package/actions/myaccount

© Stack Overflow or respective owner

Related posts about j2ee

Related posts about struts2