随笔-61  评论-13  文章-19  trackbacks-0

今天遇到个以前使用Struts没有注意的地方。
现象:
   在actionForward配置文件里面定义
   <forward name="success" path="/Catalog.jsp" redirect="true"/>

   当在提交页面里面request.setAttbriute("msg","处理成功");
   提交后在Catalog.jsp 用request.getAttbriute("msg");居然为空,原因是设置了redirect="true"

下例举例说明了redirect属性的用法:

<forward name="success" path="/Catalog.jsp" redirect="true"/>

如果 redirect=true, URL 建立如 / contextPath / path 因为 HttpServletResponse.sendRedirect(…) 中解释 URL 采用 ”/” 开头相对于 servlet 容器根目录。

如果 redirect=false, URI 建立如 / path 因为 ServletContext.getRequestDisptacher(…) 采用虚拟目录相关 URL

posted on 2006-03-14 18:04 xnabx 阅读(1334) 评论(0)  编辑  收藏 所属分类: JSP/Servlet

只有注册用户登录后才能发表评论。


网站导航: