Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to create a global-results across different packages which are under different namespaces. Can I know the conventions that required to follow in struts config file?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
457 views
Welcome To Ask or Share your Answers For Others

1 Answer

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")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...