框架学习【Spring Boot】-集成Beetl - 东南西北

东南西北

整理 思考 行动

框架学习【Spring Boot】-集成Beetl

首页 编程 0 评

引入依赖

<dependency>
            <groupId>com.ibeetl</groupId>
            <artifactId>beetl</artifactId>
            <version>2.7.12</version>
        </dependency>       
编写BeetlConf类 ------------ ```java package com.zipscloud.rbac.configurer;

import org.beetl.core.resource.ClasspathResourceLoader;
import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
import org.beetl.ext.spring.BeetlSpringViewResolver;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeetlConf {

@Bean(initMethod = "init", name = "beetlConfig")
public BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration() {

    BeetlGroupUtilConfiguration beetlGroupUtilConfiguration = new BeetlGroupUtilConfiguration();
    ClasspathResourceLoader classpathResourceLoader = new ClasspathResourceLoader();
    beetlGroupUtilConfiguration.setResourceLoader(classpathResourceLoader);

    //读取配置文件信息

// beetlGroupUtilConfiguration.setConfigFileResource(patternResolver.getResource("classpath:beetl.properties"));
return beetlGroupUtilConfiguration;
}

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

}


调整spring boot配置文件
-----------------
增加
```javascript
spring.beetl.root = classpath:/templates/
spring.beetl.prefix =
spring.beetl.suffix = .html
spring.beetl.order = 0
spring.beetl.cofig = classpath:beetl.properties

编写beetl.properties文件

#######默认配置
ENGINE=org.beetl.core.engine.FastRuntimeEngine
DELIMITER_PLACEHOLDER_START=${
DELIMITER_PLACEHOLDER_END=}
DELIMITER_STATEMENT_START=<%
DELIMITER_STATEMENT_END=%>
DIRECT_BYTE_OUTPUT = FALSE
HTML_TAG_SUPPORT = true
HTML_TAG_FLAG = #
HTML_TAG_BINDING_ATTRIBUTE = var
NATIVE_CALL = TRUE
TEMPLATE_CHARSET = UTF-8
ERROR_HANDLER = org.beetl.core.ConsoleErrorHandler
NATIVE_SECUARTY_MANAGER= org.beetl.core.DefaultNativeSecurityManager
RESOURCE_LOADER=org.beetl.core.resource.ClasspathResourceLoader
MVC_STRICT = FALSE

### 资源配置,resource后的属性只限于特定ResourceLoader ####
#classpath 跟路径
RESOURCE.root= /
#是否检测文件变化
RESOURCE.autoCheck = TRUE
#自定义脚本方法文件位置
RESOURCE.functionRoot = functions
#自定义脚本方法文件的后缀
RESOURCE.functionSuffix = html
#自定义标签文件位置
RESOURCE.tagRoot = htmltag
#自定义标签文件后缀
RESOURCE.tagSuffix = tag


#####  扩展 ##############
## 内置的方法
FN.date = org.beetl.ext.fn.DateFunction
FN.nvl = org.beetl.ext.fn.NVLFunction
FN.debug = org.beetl.ext.fn.DebugFunction
#兼容以前版本,用has代替
FN.exist = org.beetl.ext.fn.CheckExistFunction
FN.has = org.beetl.ext.fn.CheckExistFunction
FN.printf = org.beetl.ext.fn.Printf
FN.decode = org.beetl.ext.fn.DecodeFunction
FN.assert = org.beetl.ext.fn.AssertFunction
FN.print = org.beetl.ext.fn.Print
FN.println = org.beetl.ext.fn.Println
FN.trunc = org.beetl.ext.fn.TruncFunction
#兼容以前版本 empty,用isEmpty代替
FN.empty = org.beetl.ext.fn.EmptyFunction
FN.qmark = org.beetl.ext.fn.QuestionMark
FN.isEmpty = org.beetl.ext.fn.EmptyExpressionFunction
FN.parseInt = org.beetl.ext.fn.ParseInt
FN.parseLong = org.beetl.ext.fn.ParseLong
FN.parseDouble= org.beetl.ext.fn.ParseDouble
FN.range = org.beetl.ext.fn.Range
FN.flush = org.beetl.ext.fn.Flush
FN.json = org.beetl.ext.fn.Json

##内置的功能包
FNP.strutil = org.beetl.ext.fn.StringUtil
FNP.array = org.beetl.ext.fn.ArrayUtil

##内置的格式化函数
FT.dateFormat =  org.beetl.ext.format.DateFormat
FT.numberFormat =  org.beetl.ext.format.NumberFormat
##内置的默认格式化函数
FTC.java.util.Date = org.beetl.ext.format.DateFormat
FTC.java.sql.Date = org.beetl.ext.format.DateFormat
FTC.java.sql.Time = org.beetl.ext.format.DateFormat
FTC.java.sql.Timestamp = org.beetl.ext.format.DateFormat
FTC.java.lang.Short = org.beetl.ext.format.NumberFormat
FTC.java.lang.Long = org.beetl.ext.format.NumberFormat
FTC.java.lang.Integer = org.beetl.ext.format.NumberFormat
FTC.java.lang.Float = org.beetl.ext.format.NumberFormat
FTC.java.lang.Double = org.beetl.ext.format.NumberFormat
FTC.java.math.BigInteger = org.beetl.ext.format.NumberFormat
FTC.java.math.BigDecimal = org.beetl.ext.format.NumberFormat
FTC.java.util.concurrent.atomic.AtomicLong = org.beetl.ext.format.NumberFormat
FTC.java.util.concurrent.atomic.AtomicInteger = org.beetl.ext.format.NumberFormat

##虚拟属性 无
## 标签类
TAG.include= org.beetl.ext.tag.IncludeTag
TAG.includeFileTemplate= org.beetl.ext.tag.IncludeTag
TAG.layout= org.beetl.ext.tag.LayoutTag
TAG.delete= org.beetl.ext.tag.DeleteTag
TAG.htmltag= org.beetl.ext.tag.HTMLTagSupportWrapper
TAG.htmltagvar= org.beetl.ext.tag.HTMLTagVarBindingWrapper
TAG.cache= org.beetl.ext.tag.cache.CacheTag

框架学习【VUE】-组件复用