global results across different packages defined in struts configuration file

Define global result in the package that other packages extend. For example

<package name="default" extends="struts-default">
  ...
  <global-results>
    <result name="error">/pages/error_page.jsp</result>
  </global-results>
  ...
</package>

This result could be used across actions that forward to error page and as exception handling result.

If you are using conventions plugin with annotations you could define @Results annotation on the class that has the parent package other packages extend. For example

@Results({
  @Result(name = ERROR, location = "/pages/error_page.jsp"),
})

The parent package is annotated with @ParentPackage annotation. It could be placed on the class but better place it on the package. For example

package-info.java:

@ParentPackage("default")

Leave a Comment