Child pages
  • How do we configure an Interceptor to be used with every Action

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Any given action mapping can create an "ad-hoc" interceptor stack

Code Block

  <action name="login"  class="tutorial.Login">

       <interceptor-ref name="timer"/>
       <interceptor-ref name="logger"/>
       <interceptor-ref name="defaultStack"/>

        <result name="input">login.jsp</result>
        <result type="redirectAction">/secure/home</result>

 </action>

Or, we can create our own named stacks and even declare a new default interceptor stack for a package

Code Block

<package name="default" extends="struts-default" >

    <interceptors>
        <interceptor-stack name="myStack">
            <interceptor-ref name="timer"/>
            <interceptor-ref name="logger"/>
            <interceptor-ref name="defaultStack"/>
       </interceptor-stack>
    </interceptors>

    <default-interceptor-ref name="myStack"/>

    <action name="login"  class="tutorial.Login">
        <result name="input">login.jsp</result>
        <result type="redirectAction">/secure/home</result>
    </action>

</package>

Packages can extend other packages. If all the other packages in your application extend "default", then they will all inherit the new default interceptor.

...