Versions Compared

Key

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

...

The ParentPackage annotation allows applications to define different parent XWork packages Struts package for specific action classes or Java packages. Here is an example of using the annotation on an action class:

Code Block
titlecom.example.actions.HelloWorld
package com.example.actions;

import com.opensymphony.xwork2.ActionSupport; 
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;

@ParentPackage("customXWorkPackage")
public class HelloWorld extends ActionSupport {
  public String execute() {
    return SUCCESS;
  }
}

To apply this annotation to all actions in a package (and subpackages), add it to package-info.java. An alternative to this annotation is to set struts.convention.default.parent.package in XML.

ExceptionMapping Annotation

...