1、引入pom依赖

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

2、设置thymeleaf版本,版本3检查html标签可以没有闭合结束符

    <properties>
<thymeleaf.version>3.0..RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.0.</thymeleaf-layout-dialect.version>
</properties>

3、配置文件设置thymeleaf属性

spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-
spring.thymeleaf.content-type=text/html
spring.thymeleaf.mode=HTML5

4、在resources/templates新建index.html文件

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Hello World!</title>
</head>
<body>
<h1 th:inline="text">Hello</h1>
<p th:text="${hello}"></p>
</body>
</html>

5、编写controller

@RequestMapping
@Controller
public class IndexController { @GetMapping("/helloHtml")
public String testHelloHtml(Model model){
model.addAttribute("hello", "你好");
return "index";
}
}

SpringBoot中使用Thymeleaf模板的更多相关文章

  1. 在Spring MVC和Spring Boot中使用thymeleaf模板

    Spring MVC: POM: <!-- thymeleaf模板 --> <!-- https://mvnrepository.com/artifact/org.thymeleaf ...

  2. 7 — 简单了解springboot中的thymeleaf

    1.官网学习地址 https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html 2.什么是thymeleaf? 一张图看明白: 解读: ...

  3. springboot 中的 thymeleaf 页面进阶小知识

    我们做好了登录页,那设计一个场景吧,比如我们登录后跳转到公司主页,想从公司主页再跳转到员工列表页: 这样的场景我们该如何实现,首先要知道一些基础知识,就是SpringBoot的一些关于请求的架构知识: ...

  4. springboot 中使用thymeleaf

    Spring Boot支持FreeMarker.Groovy.Thymeleaf和Mustache四种模板解析引擎,官方推荐使用Thymeleaf. spring-boot-starter-thyme ...

  5. 最简单的 springboot 发送邮件,使用thymeleaf模板

    1,导入需要的包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId&g ...

  6. SpringBoot中的thymeleaf引擎报错

    关于:thymeleaf报错: An error happened during template parsing (template: "class path resource [temp ...

  7. SpringBoot 之Thymeleaf模板.

    一.前言 Thymeleaf 的出现是为了取代 JSP,虽然 JSP 存在了很长时间,并在 Java Web 开发中无处不在,但是它也存在一些缺陷: 1.JSP 最明显的问题在于它看起来像HTML或X ...

  8. Spring Boot2(五):使用Spring Boot结合Thymeleaf模板引擎使用总结

    一.Thymeleaf概述 一般来说,常用的模板引擎有JSP.Velocity.Freemarker.Thymeleaf . SpringBoot推荐的 Thymeleaf – 语法更简单,功能更强大 ...

  9. springboot 引入 thymeleaf 模板

    第一步pom中: <!-- 引入 thymeleaf 模板依赖 --> <dependency> <groupId>org.springframework.boot ...

随机推荐

  1. jdk和Tomcat版本之间的关系,jdk尽量要比tomcat低才行

    注:本文来源于:6860 <jdk和Tomcat版本之间的关系,jdk尽量要比tomcat低才行> 用的tomcat是低版本的,但是用的jdk却是高版本的,用Servlet做的项目运行都没 ...

  2. JAVA基础--环境搭建

    概况 系统:win10 企业版 IDE:Eclipse 4.7.3 JDK:jdk1.8.0_171 数据库:SQLServer2012 Oracle,未安装MySQL 安装 JDK与开发工具(Ecl ...

  3. 《京东上千页面搭建基石——CMS前后端分离演进史》阅读笔记

    一.背景 CMS即内容管理系统,目的是用于快速进行网站建设或者网页开发. 对于京东网站部门来说,CMS核心目的是用来快速开发和上线各种页面,诸如各种垂直频道页. 二.CMS核心目的 进行数据和模板的统 ...

  4. 必会的 55 个 Java 性能优化细节!一网打尽!

    阅读本文大概需要 10 分钟. 来源:https://yq.aliyun.com/articles/662001 在 Java 程序中,性能问题的大部分原因并不在于 Java 语言,而是程序本身.养成 ...

  5. zabbix 自动发现 监控 硬盘读写 disk io

    直接 上配置: 1.配置文件 cat userparameter_harddisk.conf #discovery hard diskUserParameter=custom.vfs.discover ...

  6. mysql5.7密码过期ERROR 1862 (HY000): Your password has expired. To log in you must change

    环境: ubuntu14.04  mysql5.7 一.mysql5.7 密码过期问题 报错: ERROR 1862 (HY000): Your password has expired. To lo ...

  7. [BUAA 软工]提问回顾与个人总结

    项目 内容 这个作业属于哪个课程 北航软工 这个作业的要求在哪里 提问回顾与个人总结 我在这个课程的目标是 学习如何以团队的形式开发软件,提升个人软件开发能力 这个作业在哪个具体方面帮助我实现目标 督 ...

  8. 剑指offer:序列化二叉树

    题目描述: 请实现两个函数,分别用来序列化和反序列化二叉树 思路分析: 这里一开始有点不明白题目的意思.实际上序列化应该指把二叉树用某种编码方式表示,这里一般是字符串的形式.而反序列就是将之前生成的序 ...

  9. OpenTK学习笔记:C#的中开发OpenGL程序的4种开源封包库SharpGL、CsGL、OpenTK、Tao框架的简单对比

    最近要在C#的语言环境下开发OpenGL程序,参考了网上的博客论坛http://www.cnblogs.com/hanyonglu/archive/2012/06/12/2546581.html,总结 ...

  10. python lambda表达式简单用法【转】

    python lambda表达式简单用法 1.lambda是什么? 看个例子: g = lambda x:x+1 看一下执行的结果: g(1) >>>2 g(2) >>& ...