Do Struts2 Results annotations override or add to superclass defined values?
The following example: I have a superclass and subclass for a struts action.
The superclass defines @Results
, and the subclass needs to 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 a subclass
@Results({
@Result(name=BaseAction.INDEX, location="/WEB-INF/jsp/reporting/index.jsp")
})
public class ReportAction extends BaseAction {
...
}
My question is, does an instance of ReportAction only have th开发者_Go百科e @Result
of INDEX
defined, or does it also contain any @Result
entries defined in any if it's superclasses.
Is my ReportAction
aware of the location set for BaseAction.ERROR
??
Thanks, Martin
Yes, your ReportAction class will have both BaseAction.INDEX and BaseAction.ERROR.
General super class or sub class rule will apply in this case also. If you don't find something in your subclass it will go and look into the super class.
In your case BaseAction.ERROR not found in your subclass it will go and look into the superclass.
It will have both. You can verify with the config browser plugin.
It will be able to identify both BaseAction.INDEX and BaseAction.ERROR.
If the result is available in the Subclass (In your case ReportAction class) it will follow that, Otherwise it will look in the superclass (In you case BaseAction class).
精彩评论