发新话题
打印

大家帮忙

大家帮忙

Struts中struts-config.xml中<blobal-forwards></blobal-forwards>有什么作用,我不用它也一样实现forwards呀?

TOP

据个例子吧:你的配置中:  
...  
<global-forwards>  
       <forward      name="logoff"                              path="/logoff.do"/>  
       <forward      name="logon"                                path="/logon.jsp"/>  
       <forward      name="success"                            path="/mainMenu.jsp"/>  
   </global-forwards>  
...  
<action  path="/test/test"  
           type="test.web.TestAction"  
           name="testForm"  
           scope="request"  
           input="/jsp/test.jsp">  
<forward  name="success"  path="/success.do?actionType=init"/>  
</action>  
...  
在你的TestAction中,如果你用mapping.findForward("success"),就会执行/successs.do,可是如果你用mapping.findForward("logoff");虽然你在action配置中没有定义logoff,可是因为global中有,所以会执行/logoff.do

TOP

发新话题