分类: Java
2014-03-04 10:40:10
The ParentPackage annotation allows applications to define different parent Struts package for specific action classes or Java packages. Here is an example of using the annotation on an action class:
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.
ParentPackage 这个特殊注解便可以解决