jsp页面
<body>
<a href="resulttype/r1.action">dispatcher</a>
<a href="resulttype/r2.action">redirect</a>
<br>
<a href="resulttype/dynamicResult.action?type=1">动态1</a>
<a href="resulttype/dynamicResult.action?type=2">动态2</a>
</body>
action dynamicResult.java
public class dynamicResult extends ActionSupport {
private int type;
private String r;
public int getType() {
return type;
}
public void setType(int type) {
System.out.println("type:"+type);
this.type = type;
}
public String getR() {
return r;
}
public void setR(String r) {
this.r = r;
}
public String execute(){
System.out.println("type="+type);
if(type==1){
System.out.println("type=="+type);
r="/D2/r1.jsp";
}
else if(type==2){
r="/D2/r2.jsp";
}
return "success";
}
}
struts.xml
<package name="resulttype" namespace="/resulttype" extends="struts-default">
<!-- <action name="dynamicResult" class="D2.dynamicResult">
<result name="success">${r}</result>
</action>-->
<action name="dynamicResult" class="D2.dynamicResult">
<result name="success">/D2/r${type}.jsp</result>
<!-- <result name="success" type="redirect">/D2/r${type}.jsp?t={type}</result>-->
</action>
</package>