SpringBoot整合Beetl模板引擎 加载webapp下的静态资源

本文介绍了如何在SpringBoot项目中整合Beetl模板引擎,并详细阐述了配置过程,包括在pom.xml中配置静态资源路径,application.properties中设置Beetl配置,Java代码读取配置,Beetl的扩展配置,以及如何初始化BeetlConfig以加载webapp/pages下的静态资源。最后展示了整合后的效果。
摘要由CSDN通过智能技术生成

1.加载webapp下的资源需要在pom.xml配置静态资源路径,如下配置加载resources和webapp下的静态资源

<build>
    <!--        加载静态资源-->
    <resources>
        <resource>
            <directory>src/main/webapp</directory>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
        </resource>
    </resources>
</build>

2.配置beetl的配置,在application.properties

spring.mvc.view.prefix=/pages
 
beetl.delimiter-statement-start=@
beetl.delimiter-statement-end=null
 
beetl.resource-tagroot=common/tags
beetl.resource-tagsuffix=tag
 
beetl.resource-auto-check=true

3.在java读取properties配置

package com.debug.kill.config.properties;
 
import com.debug.kill.server.utils.ToolUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
 
import java.util.Properties;
 
/**
 * beetl配置(如果需要配置别的配置可参照这个形式自己添加)
 *
 * @author ...
 * @date 2017-05-24 2
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

^止境^

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值