ActionForward详细介绍
来源:互联网 发布:淘宝店铺女装名字大全 编辑:程序博客网 时间:2024/06/04 19:15
ActionForward详细介绍
(2011-07-09 17:19:58)转载▼标签:杂谈
ActionForward详细介绍
之前说了很多关于actionForm的内容,今天就来讲解下struts种另一个比较重要的内容actionForward,相信通过前面的学习,大家对actionForward已近不陌生了,这篇文章就是来系统讲解一下actionForward的。
ActionForward详细介绍
(2011-07-09 17:19:58)杂谈
ActionForward详细介绍
其实通常我们都没写redirect属性,而是采取的是它的默认值false,表示的是转发,如果设置为true,即为重定向。
- <global-forwards>
-
<forward name="success" path="/login_success.jsp"/> - </global-forwards>
- ActionForward
af "login");= mapping.findForward( - af.setRedirect(false);
这样当然也是可以的啦,不过记住要重启服务器,因为struts-config.xml文件不允许动态修改。
- @Override
-
public ActionForward execute(ActionMapping mapping, ActionForm form, -
HttpServletRequest request, HttpServletResponse response) -
throws Exception { -
-
//重定向 -
response.sendRedirect(request.getContextPath() + "/login.jsp"); -
return null; -
-
}
注意:return null是必须的。
-
path="/dynaactionforward" -
type="com.bjsxt.struts.DynaActionForwardTestAct ion" -
> -
-
<forward name="page1" path="/page1.jsp"/> -
<forward name="page2" path="/page2.jsp"/> -
-
</action> - </action-mappings>
- <form
action= "dynaactionforward.do"method= "post"> -
页面:<input type="text" name= "page"><br> -
<input type="submit" value= "提交"> -
</form>
- public
class DynaActionForwardTestAct extendsion Action { -
@Override -
public ActionForward execute(ActionMapping mapping, ActionForm form, -
HttpServletRequest request, HttpServletResponse response) -
throws Exception { -
-
String page = request.getParameter("page"); -
ActionForward af = null; -
if ( "1".equals(page)){ -
af = mapping.findForward("page1"); -
}else if ( "2".equals(page)){ -
af = mapping.findForward("page2"); -
} -
return af; -
-
} - }
- public
class DynaActionForwardTestAct extendsion Action { -
@Override -
public ActionForward execute(ActionMapping mapping, ActionForm form, -
HttpServletRequest request, HttpServletResponse response) -
throws Exception { -
-
String page = request.getParameter("page"); -
ActionForward af = new ActionForward(); -
af.setPath("/page" + ".jsp?name=Tom");page + -
return af; -
} - }
- ActionForward详细介绍
- ActionForward详细介绍
- Struts之ActionForward详细介绍
- Struts之ActionForward详细介绍
- 自学SSH框架之---struts(七):ActionForward详细介绍
- ActionForward 用法及详细说明
- ActionForward
- ActionForward
- ActionForward
- ActionForward
- ActionForward
- ActionForward
- Struts1中ActionForward的技巧介绍
- ActionForward 讲解
- 动态ActionForward
- 关于ActionForward
- 自定义ActionForward
- ActionForward总结
- C#线程调用带参数的方法 ~
- 如何进行软件架构设计?
- IOS注意事项
- 系统设计类面试题
- 证明一个操作的一致性读过程是以自己开始执行的时间为准回滚的不是以该操作所在的事务开始的时间为准回滚的
- ActionForward详细介绍
- n后问题
- 论分享的本质
- 机器学习经典论文/survey合集
- Objective-C 2.0的运行时编程
- 系统设计面试题思路综述
- 仙剑5前传大吐糟 2013-2-5记录
- jar包和claess文件加载顺序
- 技术人创业可能面临的挑战