struts控制器中使用new ActionForward和mapping.findForward的区别
来源:互联网 发布:java输出000 编辑:程序博客网 时间:2024/05/21 17:36
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
- struts控制器中使用new ActionForward和mapping.findForward的区别
- struts控制器中使用new ActionForward和mapping.findForward的区别
- new ActionForward和mapping.findForward的区别
- struts中ActionForward 使用mapping.findForward如何传递get参数
- struts中ActionForward 使用mapping.findForward如何传递get参数
- new ActionForward和mapping.findForward(请求重定向和转发)
- mapping.findForward("") 得到struts-config 已经配置好的forward
- struts的action中使用ActionForward来转发,redirect
- 在struts的ActionForward中添加参数
- 在struts的ActionForward中添加参数
- struts中的findForward()和getinputforward()
- struts中ActionForward的也可以这样用
- Servlet Mapping 中/ 和 /*的区别
- Servlet Mapping 中/ 和 /*的区别
- struts中的findForward
- Struts中ActionForward带参数跳转
- Struts 1 学习笔记-4-4(Struts中ActionForward的测试)
- Struts页面转发控制ActionForward和ActionMapping
- Linux shell脚本编写基础
- JavaBean和反射
- SQL Server 2008的审核功能
- EOutOfResources字符异常
- 【梅花雪网页脚本控件集】MzTreeView 1.0 一次加载数据的树
- struts控制器中使用new ActionForward和mapping.findForward的区别
- Marquee 滚动的效果
- request.getRealPath(String path) Deprecated
- josso for tomcat配置 step by step
- 开发经验小结(网络编程(1))---基础小知识
- asp.net汉字转拼音类
- Linux大文件使用
- SQL Server启动服务器时运行的存储过程
- static