struts 2中的<global-forwards> </global-forwards>

时间:2014-05-17 04:58:20

标签: struts2

我们正在将我们的应用程序从Struts 1.2转换为2.16。我已经添加了所需的jar,现在我将struts_config.xml转换为struts.xml。下面是我的struts-config.xml

<struts-config>
 <global-forwards>
        <!-- Default forward to "Welcome" action -->
        <!-- Demonstrates using index.jsp to forward -->
        <forward name="welcome"  path="/Welcome.do"/>
        <forward name="family"   path="/Employee.do"/>
        <forward name="line"     path="/Owner.do"/>
   </global-forwards>
    <action-mappings>
         <action path="/Welcome" forward="/pages/welcome.jsp"/>
         <action path="/Employee" forward="/pages/employeejsp"/>
         <action path="/Owner" forward="/pages/owner.jsp"/>
    </action-mappings>

</stuts-config>

我无法将Global_forwards转换为global_results。当试图访问页面获取一个空白页面,并没有抛出任何错误。添加devmode仍然没有运气。

任何人都可以帮助我。

由于

1 个答案:

答案 0 :(得分:0)

<forward name="welcome"  path="/Welcome.do"/>
      <forward name="family" path="/Employee.do"/>
      <forward name="line" path="/Owner.do"/>
</global-forwards>

<global-results>
     <result name="family" type="redirect">Employee</result>
     <result name="line" type="redirect">Owner</result>
</global-results>

用于行动映射

<action-mappings>
         <action path="/Welcome" forward="/pages/welcome.jsp"/>
</action-mappings>
<package name="test" extends="struts-default">
    <action name="Welcome" class="org.xyz.Welcome" method="welcome">
         <result name="success">/welcome.jsp</result>
         <result name="input">/register.jsp</result>
     </action>
</package>