new ActionForward和mapping.findForward的区别
来源:互联网 发布:看鬼畜视频的软件 编辑:程序博客网 时间:2024/06/10 20:06
struts控制器中使用new ActionForward和mapping.findForward的区别
request.setAttribute("list", new Integer(0));
return new ActionForward("/success.jsp");
request.setAttribute("list", new Integer(0));
return mapping.findForward("fail");
当使用 return new ActionForward("/success.jsp");的时候相当于还是同一个request请求,所以可以携带参数setAttribute过去。
无论 <forward
name="succ"
path="/success.jsp"
redirect="true" />//无论此处的redirect是true还是false。
当使用 return mapping.findForward("fail");的时候如果 redirect="true",相当于还是另外一个request请求,所以不能携带参数setAttribute过去。
要想还是使用同一个request,获取到参数,则把
<forward
name="succ"
path="/success.jsp"
redirect="false" />//此处的redirect改为false。另外,此处不设置的话默认redirect="false"。
无论在任何情况下使用
request.getSession().setAttribute("a", "sssss");都可以传递参数。
在页面处获取 <%=request.getSession().getAttribute("a")%>
另外,使用 new ActionForward时候地址栏不会出现jsp页面,当使用session携带参数的时候会显示sessionid在地址栏,和使用mapping.findForward当redirect改为false时候效果一样。
使用 mapping.findForward的时候并且redirect是true时候效果,地址栏如 http://localhost:8087/struts/fail.jsp
- new ActionForward和mapping.findForward的区别
- struts控制器中使用new ActionForward和mapping.findForward的区别
- struts控制器中使用new ActionForward和mapping.findForward的区别
- new ActionForward和mapping.findForward(请求重定向和转发)
- struts中ActionForward 使用mapping.findForward如何传递get参数
- struts中ActionForward 使用mapping.findForward如何传递get参数
- mapping.findForward("") 得到struts-config 已经配置好的forward
- Servlet Mapping 中/ 和 /*的区别
- Servlet Mapping 中/ 和 /*的区别
- new(std::nothrow) 和 new() 的区别
- new、new()和new[]三者的区别
- override 和 new 的区别
- new和override的区别?
- new和malloc的区别
- new和using的区别
- new和override的区别
- override和new的区别
- new和override的区别
- ArcGIS 10.1 如何连接数据库
- python 文件操作
- linux中的热插拔和mdev机制
- 最短代码实现windows8下的下载器-下载安装执行一体化
- WCF承载IIS 访问错误HTTP Error 404.3-找不到 Not Found 由于扩展配置问题而无法提供您请求的页面
- new ActionForward和mapping.findForward的区别
- C语言暑期实习 第九天
- 如何学好OBJECTIVEC
- 如何用汉字的拼音对汉字排序
- 手机仍存随意处置风险
- 无废话ExtJs系列教程
- example of well-written jdbc code
- 【Cocos2d-X(2.x) 游戏开发系列之一】cocos2dx(v2.x)与(v1.x)的一些常用函数区别讲解!在2.x版CCFileData类被去除等
- hello world