ページの先頭行へ戻る
Interstage Business Application Server オープンJavaフレームワークユーザーズガイド
FUJITSU Software

2.3.4 Controllerの動作を定義する設定ファイルの作成

ユーザは定義ファイル(Struts設定ファイル)で動作内容の指示を行います。

このStruts設定ファイルの定義内容に従い、ControllerはリクエストURLごとに処理の振り分け、Actionクラスの処理結果に応じた遷移先の呼び出し、例外発生時の対応などを行います。

(struts-config.xml)

<!-- (1) -->
<!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
    "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
  <form-beans>
    <!-- (2) -->
    <form-bean name="formbean" type="sample.ExtActionForm" />
  </form-beans>
  <action-mappings>
    <!-- (3) -->
    <action path="/sample" type="sample.ExtAction" name="formbean" input="/input.jsp" >
      <!-- (4) -->
      <forward name="result" path="/result.jsp" />
    </action>
  </action-mappings>
</struts-config>

(1) DOCTYPE指定

Struts設定ファイルの構文を定めたdtdファイルを指定します。

(2) form-beans

リクエストパラメータなどを格納するJavaBeanクラスを定義します。

(3) action-mapping

リクエストパスごとに呼び出されるActionクラスを定義します。

(4) forward

処理結果を表示するページのパスを定義します。