如何在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字符串)。
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字符串)。
相关文章推荐
- struts2的action重定向到另外一个action,如何传参数?
- struts2如何从一个Action转到另外一个Action
- SQL Server 2005 - 如何在预存程序中调用另外一个预存程序
- vc中如何将一个工程的资源复制到另外一个工程?
- SQL update 的更新值来源于另外一个表,如何实现?
- android如何在一个activity中finish掉另外一个activity
- 在mysql中如何使用一个表中的数据去更新另外一个表的数据
- Android高手进阶教程(十二)之----Android 在一个应用中如何启动另外一个已安装的应用!!!
- Android 在一个应用中如何启动另外一个已安装的应用!!!
- 如何通过函数在div中插入另外一个jsp
- easy ui 如何从一个tab 跳转到另外一个tab
- Magento -不创建Block文件,如何直接包含一个.phtml文件
- [cvs]如何直接添加一个目录到服务器
- SQL Server 2005 - 如何在预存程序中调用另外一个预存程序
- 一个工程如何直接引用另一个工程? 如何打包静态库.a? 如何打包静态库.frameWork? .a和.framework的区别?
- 如何解决更新被拒绝,因为远程版本库包含您本地尚不存在的提交。这通常是因为另外 提示:一个版本库已向该引用进行了推送。再次推送前,您可能需要先整合远程变更 提示:(如 'git pull ...')。
- 在Java applet中如何显示另外一个HTML页面
- 一个整数数组,有n个整数,如何找其中m个数的和等于另外n-m个数的和?
- 如何在一个js文件中引入另外的js文件
- 在 Java 的多线程中,如何去判断给定的一个类是否是线程安全的(另外:synchronized 同步是否就一定能保证该类是线程安全的。)