码迷,mamicode.com
首页 > 其他好文 > 详细

014 新的模板引擎

时间:2018-06-06 23:54:39      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:cti   public   framework   ...   pen   依赖   启动   return   pre   

一.概述

  在springboot之中,抛弃了默认的thymeleaf作为模板引擎.


 

二 .环境的搭建

[1]配置依赖包

  我们首先需要声明的就是我们使用thymeleaf3来完成任务,比2要友好很多的.

    <properties>
        <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
        <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
    </properties>

上面的内容从springboot文档之中可以找到.

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

我们使用thymeleaf启动器来引入依赖.


 

三 .thymeleaf的基本使用

  在thymeleaf的默认配置之中,我们只需要将html文件放在templates文件下就能实现模板的使用.

测试代码:  

@Controller
public class ThymeleafController {
    
    @RequestMapping("/success")
    public String success() {
        return "success";
    }
}

html页面: 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    成功的到达了页面之上...
</body>
</html>

我们可以发现,我们的模板页面和之前使用的html页面是一样的.

014 新的模板引擎

标签:cti   public   framework   ...   pen   依赖   启动   return   pre   

原文地址:https://www.cnblogs.com/trekxu/p/9147678.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!