首页 > 编程语言 > 详细

springboot 梳理3--简单整合模板引擎thymeleaf(待修改)

时间:2021-01-29 16:35:51      阅读:32      评论:0      收藏:0      [点我收藏+]

1. pom.xml

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

 

 

2. yml

spring:

  thymeleaf:
    prefix: classpath:/templates/
    check-template-location: true
    suffix: .html
    encoding: utf-8
    servlet:
      content-type: text/html
    mode: HTML5
    cache: false

 

3.Controller层 LoginController

@Controller
public class LoginController {
    @GetMapping("/login")
    public String toLogin(Model model){
        model.addAttribute("name","sunrui");
        return "login";
    }
}

 

 

4. login.html

技术分享图片

 

 

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p th:text=" ‘hello,‘ + ${name} + ‘!‘ "/>
</body>
</html>

 

springboot 梳理3--简单整合模板引擎thymeleaf(待修改)

原文:https://www.cnblogs.com/Master-Sun/p/14344970.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!