[英]Struts2: Setting constant struts.action.extension to “,” not working
[英]How do you obtain the value of struts.action.extension in a struts2 interceptor?
我需要从拦截器访问struts.xml文件中的struts.action.extension值。 有什么建议么?
我意识到答案可能是针对Struts的先前版本,在我使用的Struts版本(struts v2.2)中不起作用。 但是,以下内容确实有效...
final ActionContext context = actionInvocation.getInvocationContext();
com.opensymphony.xwork2.util.ValueStack vs=context.getValueStack();
((ActionMapping)vs.getContext().get("struts.actionMapping")).getExtension();
...其中ActionMapping为org.apache.struts2.dispatcher.mapper.ActionMapping。
以为这可能对某人有帮助。
感谢在Struts用户列表上的Musachy Barroso,我在拦截器中添加了以下内容:
/**
* @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;
}
正如Wes Wannemacher在同一列表中指出的那样,该列表实际上不受支持,但是在将来的版本中极不可能更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.