发现 struts2+spring的一个bug

今天开发中遇到一个问题,就是当使用result 的 type 为 chain的时候 如果action交给spring 来管理的话,那么这个跳转是不经过action代码的,而是直接跳到result所指定的页面里去了  如:
执行过程如下:
action1代码->action1 result -> action2 result(这里没有经过action2 的代码)
而且这里还有个问题
如果action1 result的name配置的是input的话,那么action2 result的名字必须要有name为input的配置,
不然会提示找不到result name 为input的配置

  ,而如果不交给spring 来管理的话,那么这个步骤是正常的,执行过程如下:
action1代码->action1 result ->action2代码 —> action2 result

我想这应该算是一个bug吧,我想这应该是spring的aop引起的问题,接下来想找找引起的原因,如果有人也碰到过这样的问题,请不吝赐教

正常的struts.xml配置如下


 <package name="chain" extends="struts-default" namespace="/chain">
       		<action name="toTest">
			<result type="freemarker">/WEB-INF/templete/test1.ftl</result> 
		</action>
		<action name="step2" class="com.payx.www.web.test.TestChainAction" method="step2">
			<result name="input" type="freemarker">
			   /WEB-INF/templete/test3.ftl
			</result>
			<result name="success" type="freemarker">/WEB-INF/templete/test2.ftl</result>
		</action>		
        <action  name="step1" class="com.payx.www.web.test.TestChainAction" method="step1" >
          <result name="input" type="chain">
              <param name="actionName">step2</param>
			  <param name="namespace">/chain</param>
		  </result>
		  <result name="success" type="freemarker">/WEB-INF/templete/test4.ftl</result>
        </action>
		
    </package>



java代码如下



public class TestChainAction {
	
	private String test;
	private String test2;
	public String getTest() {
		return test;
	}
	public void setTest(String test) {
		this.test = test;
	}
	public String getTest2() {
		return test2;
	}
	public void setTest2(String test2) {
		this.test2 = test2;
	}
	
	public String step1(){
		if(test.equals(""))
			return "input";
		
		
		return "success";
	}
	
	public String step2(){
		if(test2==null)
			return "input";
		
		
		return "success";
	}

}





非正常的struts.xml配置如下


 <package name="chain" extends="struts-default" namespace="/chain">
       		<action name="toTest">
			<result type="freemarker">/WEB-INF/templete/test1.ftl</result> 
		</action>
		<action name="step2" class="testChainAction" method="step2">
			<result name="input" type="freemarker">
			   /WEB-INF/templete/test3.ftl
			</result>
			<result name="success" type="freemarker">/WEB-INF/templete/test2.ftl</result>
		</action>		
        <action  name="step1" class="class="testChainAction" method="step1" >
          <result name="input" type="chain">
              <param name="actionName">step2</param>
			  <param name="namespace">/chain</param>
		  </result>
		  <result name="success" type="freemarker">/WEB-INF/templete/test4.ftl</result>
        </action>
		
    </package>



java代码如下



public class TestChainAction {
	
	private String test;
	private String test2;
	public String getTest() {
		return test;
	}
	public void setTest(String test) {
		this.test = test;
	}
	public String getTest2() {
		return test2;
	}
	public void setTest2(String test2) {
		this.test2 = test2;
	}
	
	public String step1(){
		if(test.equals(""))
			return "input";
		
		
		return "success";
	}
	
	public String step2(){
		if(test2==null)
			return "input";
		
		
		return "success";
	}

}






你可能感兴趣的:(spring,xml,Web,struts,配置管理)