Versions Compared

Key

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

...

The ParentPackage Annotation has configures the XWork package (an XWork package is created per Java package) to extend the defined package. Multiple packages one or more defined packages. The best place for this annotation is on the package via the package-info.java file, however, for backward-compatibility, they can be specified through annotations on multiple Actions in the package.one or more Actions in the package. To determine which parent packages should be set, first, it looks for the package annotation, then adds the action annotations as they are loaded. Because the load order of Actions is undetermined, it is highly recommended you avoid putting the @ParentPackage annotation on Action classes themselves.

For example, if you wanted to set the parent package for the com.mycompany.myapp.actions package, create this package-info.java file:

Code Block
langjava

@ParentPackage("my-parent-package")
package com.mycompany.myapp.actions

import org.apache.struts2.config.ParentPackage;

To define multiple parent packages, list an array of package names:

Code Block
langjava

@ParentPackage({"my-parent-package1, my-parent-package2"})
package com.mycompany.myapp.actions

import org.apache.struts2.config.ParentPackage;

Feedback

Stay tuned to this page for additional details and documentation. If you have a chance to try the zero configuration feature, please share any experiences on dev@ and here.

...