基于maven,web项目
如果要想使用beetl模板引擎,则首先要在项目的pom.xml中加入依赖文件
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetl</artifactId>
<version>2.9.3</version>
</dependency>
资源模板加载器,最大的误区就是模板路径不对,不知道在哪找,下面就让我用示例来说明一下吧。
一、字符串资源模板加载器
//字符串模板加载器
//初始化代码
StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
//获取模板
Template t = gt.getTemplate("hello,${name}");
t.binding("name", "beetl");
//渲染结果
String str = t.render();
System.out