struts2 인터셉터에서 struts.action.exension의 값을 어떻게 얻습니까?
-
06-09-2019 - |
문제
인터셉터에서 struts.xml 파일의 struts.action.extension 값에 액세스해야합니다. 제안이 있습니까?
해결책 2
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가 같은 목록에 기록한 것처럼 이것은 실제로 지원되지 않지만 향후 릴리스에서 변경 될 가능성은 거의 없습니다.
다른 팁
나는 대답이 아마도 이전 버전의 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
누군가에게 도움이 될 것이라고 생각했습니다.
제휴하지 않습니다 StackOverflow