我们可以在action中动态指定结果集的location,其实就是在struts.xml文件中拿到action的属性而已。
UserAction
public class UserAction extends ActionSupport
{
private String path;
private String type;
public String execute()
{
if(type == "1")
{
path = "xy.jsp";
}
else path = "xy2.jsp";
return success;
}
}
Getter和Setter省略
Struts.xml
<action name="uaction" class="com.xy.UserAction">
<result>${path}</result>
</action>
简单吧。