2017-11-02 8 views
0

複数のページを持つサンプルアプリケーションを開発しています。すべてのページは共通レイアウト(CommonLayout:Header、Body、Footer)を持っています。Struts2でデフォルトのタイルレイアウトを設定する方法

<package name="myapp" extends="default" namespace="/"> 
    <action name="a"><result type="tiles">CommonLayout</result></action> 
    <action name="a/create"><result type="tiles">CommonLayout</result></action> 
    <action name="b"><result type="tiles">CommonLayout</result></action> 
    <action name="b/customize"><result type="tiles">CommonLayout</result></action> 
    <action name="b/customize/app"><result type="tiles">CommonLayout</result></action> 
    <action name="d/create"><result type="tiles">CommonLayout</result></action> 
    <action name="d/view"><result type="tiles">CommonLayout</result></action> 
    <action name="d/view/list"><result type="tiles">CommonLayout</result></action> 
</package> 

私がアクションを追加していたびに、私はすべてのアクションに対して同じ行を複製する必要があり、すべてのアクションのレイアウトを言及する任意の構成はありますか?

答えて

1

パッケージごとにグローバル結果を使用できます。例えば、

<package name="default" extends="struts-default"> 
    ... 
    <global-results> 
    <result type="tiles">CommonLayout</result> 
    </global-results> 
    ... 
</package> 
<package name="myapp" extends="default" namespace="/"> 
    <action name="a"/> 
    <action name="a/create"/> 
    <action name="b"/> 
    <action name="b/customize"/> 
    <action name="b/customize/app"/> 
    <action name="d/create"/> 
    <action name="d/view"/> 
    <action name="d/view/list"/> 
</package> 
関連する問題