Struts の 転送 は、あるアクションによって 戻されるオブジェクトで、名前とパス (一般的には、JSP ファイルの URL) の 2 つのフィールドを持ちます。パスは、要求の送り先を示します。転送は、(特定のアクションに関係した) ローカルな転送になることも、(すべてのアクションに利用できる) グ ローバルな転送になることもあります。
転送は、グローバルな転送になることも、ローカルな転送になることもあります。グローバル転送は、Struts 構成ファイルで定義し、JSP ページで呼び出します。ローカル転送は、アクション・マッピング内の Struts 構成ファイルで定義し、アクションを呼び出すと呼び出されます。
以下は、struts-example サンプル・アプリケーションの struts-config.xml ファイル内にあるグローバル転送の例です。
<global-forwards> <forward name="logoff" path="/logoff.do"/> <forward name="logon" path="/logon.jsp"/> <forward name="success" path="/mainMenu.jsp"/> </global-forwards>
logoff 転送は、 次のように mainMenu.jsp で呼び出されます。
<html:link forward="logoff"><bean:message key="mainMenu.logoff"/></html:link>
以下は、struts-example サンプル・アプリケーションの struts-config.xml ファイル内にあるローカル転送の 例です。
<action path="/editSubscription" type="org.apache.struts.webapp.example.EditSubscriptionAction" attribute="subscriptionForm" scope="request" validate="false"> <forward name="failure" path="/mainMenu.jsp"/> <forward name="success" path="/subscription.jsp"/> </action>