Struts2.xml配置
<action name="dynamicresult" class="com.clq.Struts2_0100_Introduction.UserAction">
<result name="success" type="redirect">
/user_success.action?t=${type}
</result>
</action>UserAction:
public class UserAction extends ActionSupport { /**
*
*/
private static final long serialVersionUID = 1L;
private int type;
private String r;
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;
}
public String execute() throws Exception {
if(type == 1) r = "/Student_Add";
else r = "/Student_Delete";
return "success";
}
public String add() throws Exception {
return "aaa";
}
}报错:Invalid result location value/parameter
<action name="dynamicresult" class="com.clq.Struts2_0100_Introduction.UserAction">
<result name="success" type="redirect">
/user_success.action?t=${type}
</result>
</action>UserAction:
public class UserAction extends ActionSupport { /**
*
*/
private static final long serialVersionUID = 1L;
private int type;
private String r;
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;
}
public String execute() throws Exception {
if(type == 1) r = "/Student_Add";
else r = "/Student_Delete";
return "success";
}
public String add() throws Exception {
return "aaa";
}
}报错:Invalid result location value/parameter
http://blog.csdn.net/zhiweianran/article/details/8437701
<action name="action1" class="com.sunflower.action.Action1">
<result name="success" type="redirectAction">
<param name="actionName">action2</param>
<param name="username">${username}</param>
<param name="password">${password}</param>
</result>
</action> <action name="action2" class="com.sunflower.action.Action2">
<result name="success">action2.jsp</result>
</action>这么写试试
去掉build较检,保留手动较检试一下!