Reputation: 2360
I need to access the struts.action.extension value in the struts.xml file from an interceptor. Any suggestions?
Upvotes: 0
Views: 583
Reputation: 100
I realize the answer is probably for a previous version of struts, it did not work in the version of struts I'm using (struts v2.2). The following did work, though...
final ActionContext context = actionInvocation.getInvocationContext();
com.opensymphony.xwork2.util.ValueStack vs=context.getValueStack();
((ActionMapping)vs.getContext().get("struts.actionMapping")).getExtension();
... where ActionMapping is org.apache.struts2.dispatcher.mapper.ActionMapping.
Thought it might help someone.
Upvotes: 1
Reputation: 2360
Thanks to Musachy Barroso over on the Struts User list I added the following to my interceptor:
/**
* @param strutsActionExtension the strutsActionExtension to set
*/
@Inject(StrutsConstants.STRUTS_ACTION_EXTENSION) //Note this isn't necessarily supported
public void setStrutsActionExtension(String strutsActionExtension) {
this.strutsActionExtension = strutsActionExtension;
}
as Wes Wannemacher notes on the same list this in't actually supported but is extremely unlikely to change in future releases.
Upvotes: 0