Do Struts2 result annotations complete or add to specific superclass values?

The following example: I have a superclass and a subclass for the struts action. The superclass defines @Results , and the subclass must define additional specific @Result entries. For example:

 @Results({ @Result(name=BaseAction.ERROR, location="/WEB-INF/jsp/error.jsp") }) public abstract class BaseAction extends ActionSupport implements ServletRequestAware { ... } 

.. and subclass

 @Results({ @Result(name=BaseAction.INDEX, location="/WEB-INF/jsp/reporting/index.jsp") }) public class ReportAction extends BaseAction { ... } 

My question is whether the ReportAction instance has only @Result of INDEX , or does it also contain any @Result records defined anyway, if they are superclasses. My ReportAction knows about the location set for BaseAction.ERROR ??

Thanks Martin

+8
java superclass annotations struts2
source share
3 answers

Yes, your ReportAction class will have both BaseAction.INDEX and BaseAction.ERROR.

In this case, the superclass or subclass rule will also apply. If you do not find something in your subclass, it will go and look into the superclass.

In your case, BaseAction.ERROR is not found in your subclass, it will go and look in the superclass.

+1
source share

He will have both. You can check with the configuration browser plugin.

0
source share

It will be able to identify both BaseAction.INDEX and BaseAction.ERROR.

If the result is available in a subclass (in your case, the ReportAction class), it will follow this, otherwise it will look in the superclass (in your case, BaseAction).

0
source share

All Articles