首页 > 其他 > 详细

Struts1 中的 global-forward

时间:2014-03-16 00:15:28      阅读:501      评论:0      收藏:0      [点我收藏+]

全局forward ,struts先从局部找name,若没有再从全局找name:


     <global-forwards>
         <forward name="login" path="/login.jsp" />
     </global-forwards>

 对应到Struts2中的global-result

在struts-config.xml的文件中我们配置了许多的action,每一个action中都可以有多个forward,当页面发送请求后,RequestProcessor会根据请求的URI到struts-config.xml中寻找相应的Action对象,Action对象会根据不同的条件得到不同的ActionForward对象,ActionServlet根据不同的ActionForward指向不同的页面。

 

如果在多个action中都有相同的forward指向相同的页面,那么这些相同的forward就可以统一的配置到global-forwards中,而不需要重复的出现在各个action中,减少配置文件的复杂性。例如:

 

<struts-config>  
  1.         <!--这些forward是多个action都有的,放到这里统一管理-->  
  2.     <global-forwards>  
  3.         <forward name="exit" path="/index.jsp"/>  
  4.     </global-forwards>  
  5.     <action-mappings>  
  6.         <action path="/hello" type="com.king.action.HelloAction">  
  7.             <forward name="helloUser" path="/WEB-INF/pages/hello.jsp"/>  
  8.         </action>  
  9.     </action-mappings>  
  10. </struts-config>  

Struts1 中的 global-forward,布布扣,bubuko.com

Struts1 中的 global-forward

原文:http://www.cnblogs.com/BillPak/p/3602202.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!