Struts2_1700_DynamicResult

动态结果
一定不要忘了为动态结果的保存值设置set get方法

 

这是jsp里的内容

 

<li><a href="user/user?type=1" mce_href="user/user?type=1">返回success</a></li> <li><a href="user/user?type=2" mce_href="user/user?type=2">返回error</a></li>

action类里的内容

public class UserAction extends ActionSupport { private int type; private String r; public String getR() { return r; } public void setR(String r) { this.r = r; } public int getType() { return type; } public void setType(int type) { this.type = type; } @Override public String execute() throws Exception { if(type == 1) r="/user_success.jsp"; else if (type == 2) r="/user_error.jsp"; return "success"; } }

 

 

struts.xml

<action name="user" class="com.bjsxt.struts2.user.action.UserAction"> <result>${r}</result> </action>

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(exception,jsp,struts,String,Class,action)