【转载】Struts2 使用annotation从action跳转到action并传递参数
程序员文章站
2022-03-03 09:00:17
...
来源:http://www.blogjava.net/hhhaaawwwkkk/archive/2012/03/23/370135.html
MyAction.java
package com.zzn.action; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import com.opensymphony.xwork2.ActionSupport; @Results( { @Result(name="aaaa",location="aaaa!aaaa.action",type="redirect", params = {"flag","${flag}","flag2","${flag2}"}), @Result(name="bbbb",location="bbbb!bbbb.action",type="redirect", params = {"flag","${flag}","flag2","${flag2}"} ) } ) public class MyAction extends ActionSupport{ private String flag ; private String flag2; public String jump(){ if(flag!=null&&flag.equals("aaaa")){ return "aaaa"; }else{ return "bbbb"; } } public String getFlag() { return flag; } public void setFlag(String flag) { this.flag = flag; } public String getFlag2() { return flag2; } public void setFlag2(String flag2) { this.flag2 = flag2; } }
AaaaAction.java
package com.zzn.action; import com.opensymphony.xwork2.ActionSupport; public class AaaaAction extends ActionSupport { private String flag; private String flag2; public String aaaa(){ System.out.println("我调用的aaaa方法"+flag+"~~~~~"+flag2); return "page"; } public String getFlag() { return flag; } public void setFlag(String flag) { this.flag = flag; } public String getFlag2() { return flag2; } public void setFlag2(String flag2) { this.flag2 = flag2; } }
BbbbAction.java
package com.zzn.action; import com.opensymphony.xwork2.ActionSupport; public class BbbbAction extends ActionSupport { private String flag; private String flag2; public String bbbb(){ System.out.println("我调用的bbb方法"+flag); return "page"; } public String getFlag() { return flag; } public void setFlag(String flag) { this.flag = flag; } public String getFlag2() { return flag2; } public void setFlag2(String flag2) { this.flag2 = flag2; } }
下一篇: python相关知识点