struts2 重定向,从action直接提交到另一个action,带参数

重定向需要在struts.xml中配置redirectAction
action需要有个全局变量或实体,并且需要有setter/getter

如:
1.action:

package com.test.action;

public class TestAction extends BaseAction implements Preparable {
	Test test = new Test();
	
	public String test() throws Exception {
		test.setId(111111111);
		return "toNextTest";
	}
	
	public Test getTest() {
		return test;
	}

	public void setTest(Test test) {
		this.test = test;
	}
}


2.struts.xml配置文件

<action name="memberLogin" class="userAction" method="login">
	<result type="redirectAction" name="toNextTest">toNextTest?test.id=${test.id}</result>
</action>


黑色头发:http://heisetoufa.iteye.com

你可能感兴趣的:(struts2,重定向,传参,action,redirectAction)