5

私は現在、自分のWebアプリを使用Spring 3.0.4しています。Apache Tiles 2.2.2JSPをに置き換えたいのApache Velocity 1.6.3ですが、これを行う方法について少し混乱しています。最終的には、タイルの定義で次のことを実行できるようにしたいと思います。

<definition name="basicLayout" template="/WEB-INF/layout/basicLayout.vm">
    <put-attribute name="header" value="/WEB-INF/layout/header.vm" />
    <put-attribute name="content-area" value="/WEB-INF/layout/content.vm" />
    <put-attribute name="footer" value="/WEB-INF/layout/footer.vm" />
</definition>

これは可能ですか?もしそうなら、それをサポートするためにカスタムビュークラスを作成する必要がありますか?現在、標準のSpring VelocityConfigurer、TilesConfigurer、VelocityView、TilesViewクラスを使用しています。

ありがとう!

4

2 に答える 2

2

タイルと速度の統合を含むヘルパー クラスを作成しました: https://github.com/pete911/openhouse-web 下にスクロールすると説明があります。クラスはmaven centralにもあります。

于 2011-05-25T10:23:27.997 に答える
0

サーブレット定義内には、次のものが必要です。

    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass">
        <value>
            org.springframework.web.servlet.view.tiles2.TilesView
    </value>
    </property>
</bean>
<bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/tiles.xml</value>
        </list>
    </property>
</bean>

ご覧のとおり、 tiles.xml を宣言しています。これは、定義名などを保持するファイルです。

Maven を使用している場合は、次の依存関係が必要です。

<dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-api</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-servlet</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-template</artifactId>
        <version>2.2.1</version>
    </dependency>
于 2011-03-03T14:51:43.947 に答える