宋子宪博客

SpringBoot集成beetl模板快速入门

在pom文件引入maven依赖

   <dependency>
        <groupId>com.ibeetl</groupId>
        <artifactId>beetl-framework-starter</artifactId>
        <version>1.1.81.RELEASE</version>
    </dependency>

写一个controller

/**
 * @author songzixian
 * @create 2019-05-21 下午 3:27
 * @description
 */
    @Controller
    public class Index {
    
        @RequestMapping("/")
        public String index(HttpServletRequest request){
    
            request.setAttribute("test"," Spring Boot集成Beetl成功");
            return "index.btl";
        }
    
    }

在resources目录建立一个index.btl文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
</head>
<body>

${test}

</body>
</html>

启动项目,测试

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »