繁体   English   中英

使用Velocity with Tiles和Spring

[英]Using Velocity with Tiles and Spring

我目前在我的网络应用程序中使用Spring 3.0.4Apache Tiles 2.2.2 我想用Apache Velocity 1.6.3取代JSP,但我对如何做到这一点感到困惑。 最后,我希望能够在Tiles定义中执行以下操作:

<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类。

谢谢!

我已经创建了辅助类,其中包括与velocity集成的tile: https//github.com/pete911/openhouse-web当你向下滚动时有一个descritption。 课程也可以在maven中心找到。

在servlet定义中,您需要以下内容:

    <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 ..这是保存definiotion名称等的文件。

如果您使用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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM