标签:
在struts.xml中配置:
<action name="login" class="cn.orlion.user.UserAction" method="login"> <result> ${r} </result> </action>
UserAction:
package cn.orlion.user; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport{ private int type; private String r; public String login(){ if (1 == type) r = "/a1.jsp"; else if (2 == type) r = "/a2.jsp"; return "success"; } public int getType() { return type; } public void setType(int type) { this.type = type; } public String getR() { return r; } public void setR(String r) { this.r = r; } }
这样当访问http://localhost:8080/Struts2Demo/user/login.action?type=1时就会看到a1.jsp
访问...?type=2时就会看到a2.jsp了
struts.xml中${r} 实际是从Value Stack中取出r的值
标签:
原文地址:http://www.cnblogs.com/orlion/p/5017545.html