Spring Boot + Beetl配置问题

场景:1. 刚开始用Beetl,不是很熟悉css

           2. 原来的配置出现了beetl classes!/templates错误(最可怕的是原来配置在idea中能够直接跑,打成jar就用不得了)html

记录一下当前配置,之后再修改优化。java

BeetlConf.java(官网配置):app

@Configuration
public class BeetlConf {

    @Value("${beetl.templatesPath}") String templatesPath;//模板跟目录
    @Bean(initMethod = "init", name = "beetlConfig")
    public BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration() {
        BeetlGroupUtilConfiguration beetlGroupUtilConfiguration = new BeetlGroupUtilConfiguration();
        try {
            ClasspathResourceLoader cploder = new ClasspathResourceLoader(BeetlConf.class.getClassLoader(),templatesPath);
            beetlGroupUtilConfiguration.setResourceLoader(cploder);
            return beetlGroupUtilConfiguration;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

    @Bean(name = "beetlViewResolver")
    public BeetlSpringViewResolver getBeetlSpringViewResolver(@Qualifier("beetlConfig") BeetlGroupUtilConfiguration beetlGroupUtilConfiguration) {
        BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
        beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
        beetlSpringViewResolver.setOrder(0);
        beetlSpringViewResolver.setConfig(beetlGroupUtilConfiguration);
        return beetlSpringViewResolver;
    }

}

appliaction.properties:ide

### beetl配置
## 模板根目录
beetl.templatesPath=/templates

Controller:学习

@RequestMapping("/home")
    public String home(Admin u, Model model) {
        return "/back/home.btl";
    }

templates目录结构:优化

loanReqList.btl中include:idea

<% include("/back/common/_css.btl"){}%>

Beetl是个好东西,不断学习中...spa

相关文章
相关标签/搜索