Versions Compared

Key

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

...

The AbstractInterceptor class provides an empty implementation of init and destroy, and can be used if these methods are not going to be implemented.

Mapping

...

Interceptors are declared using the interceptor element, nested inside the interceptors element. Example from struts-default.xml:

Code Block
XML
XML

<struts>
   ...

   <package name="struts-default">
      <interceptors>
         <interceptor name="alias" class="com.opensymphony.xwork2.interceptor.AliasInterceptor"/>
         <interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
         ...
      </interceptors>
   </package>

   ...
</struts>

Example

Assuming there is an action of type "MyAction", with a setDate(Date) method, this simple interceptor will set the date of the action to the current date:

...