参考:
https://www.cnblogs.com/han-1034683568/p/7520012.html

在pom文件中加入依赖

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

在application.properties中加入

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

在resources文件夹下新增templates目录,用于存放模板文件,新增hello.html。

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

HelloController:

/*** author:13* date:2017-09-14*/
@Controller
public class HelloController {@RequestMapping("/hello")public String hello(HttpServletRequest request, @RequestParam(value = "name", required = false, defaultValue = "springboot-thymeleaf") String name) {request.setAttribute("name", name);return "hello";}
}

WebApplication:

/*** author:13* date:2017-09-14*/
@SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {@Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder application) {return application.sources(WebApplication.class);}public static void main(String[] args) throws Exception {SpringApplication.run(WebApplication.class, args);}
}

springboot使用Thymeleaf引入html文件相关推荐

  1. Springboot+thymeleaf+IDEA——如何引入模版文件,fragment ,th:include

    文章目录 Springboot+thymeleaf+IDEA--如何引入模版文件,fragment ,th:include 1.创建模版文件 2.如何引入模版文件 Springboot+thymele ...

  2. 基于springboot+bootstrap+thymeleaf的物联网一站式宠物管理平台(领养、救助、商城)设计 毕业论文+用户手册+源码清单+项目源码及数据库文件

    下载:https://download.csdn.net/download/m0_66682818/77957797 项目介绍: 基于springboot+bootstrap+thymeleaf的物联 ...

  3. spring boot构建基础版web项目(一)springboot、thymeleaf控制层基础构

    原文作者:弥诺R 原文地址:http://www.minuor.com/147852147/article 转载声明:转载请注明原文地址,注意版权维护,谢谢! 写前说明 根据个人在各篇博文中看到的信息 ...

  4. thymeleaf引入css js写法

    以下是HTML引入方法,如果springboot使用thymeleaf模板,下面写法无法正常引入资源文件,需改为thymeleaf引入方法 HTML引入方法: <link href=" ...

  5. Springboot整合thymeleaf模板

    Thymeleaf是个XML/XHTML/HTML5模板引擎,可以用于Web与非Web应用. Thymeleaf的主要目标在于提供一种可被浏览器正确显示的.格式良好的模板创建方式,因此也可以用作静态建 ...

  6. 【Springboot学习笔记】SpringBoot+Mybatis+Thymeleaf+Layui数据表单从零开始实现按条件模糊分页查询的方法

    [Springboot学习笔记]SpringBoot+Mybatis+Thymeleaf+Layui数据表单从零开始实现按条件模糊分页查询的方法 目录 1.搭建环境 1.1直接从网上下载SpringB ...

  7. springboot之thymeleaf入门

    springboot之thymeleaf入门 由于JSP是不能在压缩包内解析的,所以spring boot默认不支持JSP的.因此我们需要使用第三方的模板引擎,比如我们这次介绍的thymeleaf 官 ...

  8. thymeleaf引入css资源无效

    springBoot项目的resources文件夹下存在两个文件夹(static和templates),static文件夹下存放css.js.图片等各种静态资源,templates下存放html文件 ...

  9. springboot+mybatis+thymeleaf学习一个简单的管理系统

    在淘宝上买的课程的一个例子,看了视频,抄了一遍代码,那时候刚开始学springboot,所以感觉没什么用,然后就又学习了一段时间.最近回想起来有这样的一个系统符合我现阶段的学习程度,然后就又写了一遍. ...

最新文章

  1. rknn 学习资料整理
  2. Linux shell 编程入门 - 使用ubuntu-14.10
  3. 如何使用JCA (J2EE 连接器架构)实现企业应用--转载
  4. idea ssh连接mysql数据库_mysql命令行客户端如何通过ssh服务器连接数据库啊?
  5. Smart field 1 how is smartField controller loaded - how is main view defined in manifest.json
  6. 可反复擦写5万次的手写板,竟然还能用橡皮擦能清除屏幕!
  7. Codeforces Round #603 (Div. 2) E. Editor 线段树维护括号序列
  8. linux dhcp 负载均衡,dhcp双机负载均衡
  9. matlab散点图与colorbar,MATLAB如何为图像做colorbar
  10. 20180601 -1
  11. mysql去重函数的使用方法_MySQL中使用去重distinct方法的示例详解
  12. 获取对象的key_玩转 SpringBoot2.x 之缓存对象
  13. python库之pyserial用法,pyserial和serial的区别
  14. 移动应用/APP的测试流程及方法
  15. WT2003H4-16S 语音芯片按键录音及播放应用解析
  16. 赚钱方式决定你的财富自由之路
  17. Access Key / Secret key 密钥安全原理架构
  18. 搭建Bitbucket项目管理工具详细教程
  19. 20162316刘诚昊 用数组实现循环队列
  20. 《程序员的自我修养》读书笔记——动态链接

热门文章

  1. python event多线程回调
  2. free() invalid next size异常
  3. 曼哈顿距离,欧式距离,明式距离,切比雪夫距离,汉明距离
  4. java list《》_Java中List集合的遍历
  5. java 弱引用 集合_java 弱引用集合类WeakHashMap
  6. java基础习题集_java基础集合经典训练题
  7. mfc 弹框只出现一次_只出现一次的数字
  8. ateq测漏仪f620说明书_手环测漏仪规格齐全-同江
  9. Selenium3自动化测试——11. 下拉框处理
  10. python 上传文件夹,python – 使用Flask上传文件夹/文件