Struts2:莫名其妙的There is no Action 地图ped for namespace 异常

Struts2:莫名其妙的There is no Action mapped for namespace 错误。
There is no Action mapped for namespace XXXXXXXXXXXX and action name login. - [unknown location] 

    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:34)
    com.opensymphony.xwork2.ActionChainResult.execute(ActionChainResult.java:225)
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
    com.sinotrans.common.webapp.ActionInterceptor.intercept(ActionInterceptor.java:38)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)

 

最近在使用struts2的时候,将result type配置为chain来实现action间的调用。在新搭建的SSH中,可以正常运行。在与公司的系统集成时,总报出如上错误。

       重写过ActionChainResult,StrutsActionProxyFactory未找出原因。最后发现,原来默认struts2的result的初始化是使用自动类型注入来运行构造函数的。因为ActionChainResult是有带参数的构造函数(如下)。在公司的系统中,刚好注册了一个sql的bean,类似又为java.lang.String。二者一拍即合。每每Result中的namespace,actionName,methodName都变成同样的“XXXXX”(配置sql处写为XXXX)。

      两种解决方法:

           一,在我们的spring配置文件中,再加一个java.lang.String的bean,作冗余。有多个同样类型的bean存在,就不会自动注入到result中。

           二,继承原来的ActionChainResult,并去掉带有String类型参数的构造函数。并在struts.xml注册

   ActionChainResult.java

 

    public ActionChainResult(String namespace, String actionName, String methodName) {
        this.namespace = namespace;
        this.actionName = actionName;
        this.methodName = methodName;
    }

    public ActionChainResult(String namespace, String actionName, String methodName, String skipActions) {
        this.namespace = namespace;
        this.actionName = actionName;
        this.methodName = methodName;
        this.skipActions = skipActions;
    }

 

 

   struts.xml

<package name="common" extends="struts-default">
		<result-types>
			<result-type name="chain" class="com.simon.common.webapp.ActionChainResult"></result-type>
		</result-types>
	</package>
	
	<package name="biz-inv" namespace="/" extends="common">