jetbrick-template-1.x 旧版文档请看这里:http://subchen.github.io/jetbrick-template/1x/

§Spring webmvc 集成

jetbrick-template 可以和 Spring webmvc 进行集成。

§1. Maven 依赖

<dependency>
    <groupId>com.github.subchen</groupId>
    <artifactId>jetbrick-template-springmvc</artifactId>
    <version>2.1.2</version>
</dependency>

§2. application-context.xml 配置

<bean id="viewResolver" class="jetbrick.template.web.springmvc.JetTemplateViewResolver">
    <property name="order" value="1" />
    <property name="contentType" value="text/html; charset=utf-8" />
    <property name="suffix" value=".jetx" />

    <!-- 指定配置文件 -->
    <property name="configLocation" value="/WEB-INF/jetbrick-template.properties" />

    <!-- 直接配置属性 -->
    <property name="configProperties">
        <props>
            <prop key="jetx.input.encoding">utf-8</prop>
            <prop key="jetx.output.encoding">utf-8</prop>
        </props>
    </property>
</bean>

小心
* 如果你同时指定 configLocationconfigProperties 属性,那么 configLocation 文件中的属性优先级高。
* 请不应该在使用 viewResolverprefix 属性,用模板的 $loader.root 代替

§3. Spring-boot 集成

范例请参考: https://github.com/yingzhuo/springboot-jetx2-examples

§4. 范例源码

具体例子代码参考: https://github.com/subchen/jetbrick-template-2x-samples/