今天遇到個(gè)以前使用Struts沒(méi)有注意的地方。
現(xiàn)象:
?? 在actionForward配置文件里面定義
???<forward name="success" path="/Catalog.jsp" redirect="true"/>
?? 當(dāng)在提交頁(yè)面里面request.setAttbriute("msg","處理成功");
?? 提交后在Catalog.jsp 用request.getAttbriute("msg");居然為空,原因是設(shè)置了redirect="true"
下例舉例說(shuō)明了redirect屬性的用法:
<forward name="success" path="/Catalog.jsp" redirect="true"/>
如果
redirect=true, URL
建立如
/
contextPath
/
path
因?yàn)?/span>
HttpServletResponse.sendRedirect(…)
中解釋
URL
采用
”/”
開(kāi)頭相對(duì)于
servlet
容器根目錄。
如果
redirect=false, URI
建立如
/
path
因?yàn)?/span>
ServletContext.getRequestDisptacher(…)
采用虛擬目錄相關(guān)
URL
。
posted on 2006-03-14 18:04
xnabx 閱讀(1351)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
JSP/Servlet