您的位置:首页 > 其它

如何在Action中写Action直接重定向至另外一个Action

2013-03-12 17:38 218 查看
在写一个ACTION时,得到的结果是一系列图片,例如:

Q:如何在Action中写Action直接重定向至另外一个Action

点击某张图片则跳转至相应的界面,此时在对应的ACTION的BEAN文件里该如何写这个方法呢?

@Action(value = "foodMap", results = {

@Result(name = "success1", location = "getSolarTerm1.action?flag=1", type="redirect"),

@Result(name = "success2", location = "getSolarTerm2.action?flag=2", type="redirect"),

@Result(name = "success3", location = "getSolarTerm3.action?flag=3", type="redirect"),

@Result(name = "success4", location = "getSolarTerm4.action?flag=4", type="redirect"),

@Result(name = "success5", location = "getSolarTerm5.action?flag=5", type="redirect"),

@Result(name = "error", location = "/error.jsp") })

public String FoodMap() {

if(MMstFunctionKeyId==1)

{

return "success1";

}

else if(MMstFunctionKeyId==2)

{

return "success2";

}

else if(MMstFunctionKeyId==3)

{

return "success3";

}

else if(MMstFunctionKeyId==4)

{

return "success4";

}

else if(MMstFunctionKeyId==5)

{

return "success5";

}

return ERROR;

}

如上代码即可使不同的图片重定向只其对应的ACTION界面。

@Result(name = "success1", location = "getSolarTerm1.action?flag=1", type="redirect"),

那么即对应的return的值,location即对应重定向的ACTION,flag用于标示区分从那个图片进图到某个ACTION,TYPE有很多种类型,很强大,但是一般情况下采用redirect(重定向),json(json字符串)。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐