[SpringBoot2]Thymeleaf
- 引入starter
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>
- 自动配置好了thymeleaf
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(ThymeleafProperties.class)
@ConditionalOnClass({ TemplateMode.class, SpringTemplateEngine.class })
@AutoConfigureAfter({ WebMvcAutoConfiguration.class, WebFluxAutoConfiguration.class })
public class ThymeleafAutoConfiguration { }
自动配好的策略
● 1、所有thymeleaf的配置值都在 ThymeleafProperties
● 2、配置好了 SpringTemplateEngine
● 3、配好了 ThymeleafViewResolver
● 4、我们只需要直接开发页面
public static final String DEFAULT_PREFIX = "classpath:/templates/";public static final String DEFAULT_SUFFIX = ".html"; //xxx.html
- 名称空间
xmlns:th="http://www.thymeleaf.org"
测试:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body>
<h1 th:text="${msg}">哈哈</h1>
<h2><a href="www.atguigu.com" th:href="${link}">去百度</a> <br/><a href="www.atguigu.com" th:href="@{link}">去百度2</a>
</h2>
</body>
</html>
@Controller
public class ViewTestController {@GetMapping("/atguigu")public String atguigu(Model model){//model中的数据会被放在请求域中,相当于request.setAttribute("a",aa)model.addAttribute("msg","hello,world");model.addAttribute("link","http://www.baidu.com");return "success";}}
[SpringBoot2]Thymeleaf相关推荐
- springboot2 + thymeleaf + shiro1.4+redis里前端shiro标签没法用
自打用了shiro,项目是三天两头出BUG...同样的配置摆在我这就不成...心痛 如今遇到了个更奇怪的问题,是前后端耦合的项目,直接调Index.html里的登陆接口可以实现登陆,但加上shiro标 ...
- springboot2.3.x版本对应的spring5与thymeleaf版本配置
1.由于springboot2.3.2中自带的spring5,我这里用的java8,不指定thymeleaf版本情况下默认的thymeleaf版本应该是thymeleaf2.而2版本总会出现问题,我遇 ...
- 玩转springboot2.x之搭建Thymeleaf官方示例程序
1 thymeleaf 官方示例程序介绍 前面我已经介绍了如何在spirngboot2.0中使用freemarker和jsp,今天我们来说一下如何在springboot2.0中如何使用Thymelea ...
- SpringBoot2.x 集成 Thymeleaf
本文主要对SpringBoot2.x集成Thymeleaf及其常用语法进行简单总结,其中SpringBoot使用的2.4.5版本. 一.Thymeleaf简介 Thymeleaf是面向Web和独立环境 ...
- SpringBoot2.1.5(33)---SpringBoot整合 Thymeleaf 模板引擎
目录 一. Thymeleaf 简介: 官网 官方文档 入门资料参考: 二.代码实践 1.maven依赖 2.yml 文件 配置 3.Thymeleaf 文件 4.测试Controller 5.启动项 ...
- SpringBoot2.0系列(2)---SpringBoot之使用Thymeleaf视图模板
前言 Thymeleaf 是Java服务端的模板引擎,与传统的JSP不同,前者可以使用浏览器直接打开,因为可以忽略掉拓展属性,相当于打开原生页面,给前端人员也带来一定的便利.如果你已经厌倦了JSP+J ...
- 《SpringBoot2.0 实战》系列-整合FlyingSaucer + thymeleaf 实现模板文件转pdf打印
前言 最近,接到一个模板打印pdf的任务,后来网上找了很多案例,本文做下记录. 如何开始 添加依赖包 <!-- thymeleaf --> <dependency><gr ...
- 《SpringBoot2.0 实战》系列-整合thymeleaf 实现模板文件转word打印
前言 最近,有小伙伴看了我的<模板文件转pdf打印>文章后,私信问我,有没有转word的demo.当时只能遗憾的说没有.所以就有了这篇文章. 如何开始 thymeleaf 依赖包 < ...
- 《SpringBoot2.0 实战》系列-整合thymeleaf 实现模板文件转图片
前言 之前写了两篇关于动态模板转pdf和word的文章:<模板文件转pdf打印>.<模板文件转word打印>,最近又接到一个需求需要转图片,所以本文做下记录. 如何开始 thy ...
最新文章
- 参考答案:05 实对称矩阵与二次型
- MOSS User Profile(一):获取和遍历
- 使用elementui实现表单上传功能_使用ElementUI中的upload组件上传Excel文件
- Android安卓开发-eclipse正确添加第三方jar包
- springboot起步配置和自动配置原理
- 利用多个域名来存储网站资源
- 数据挖掘算法_数据挖掘算法入门
- 若只让我推荐一名LiveVideoStackCon上海的讲师,就是他
- 前端学习(159):meta
- 1756冗余_AB冗余模块1756-RM
- Diango博客--17.统计各个分类和标签下的文章数
- 拍照购物APP之可行性分析
- HALCON 20.11:标定助手使用注意事项
- python中trun是什么意思_Python 中 'unicodeescape' codec can't decode bytes in position XXX: trun错误解...
- 李宏毅机器学习——梯度下降
- ubuntu dns 解析失败
- lg-1 x 怎么算_纯爱|电竞新文《队友太会撒娇了怎么办》《转会后我成了团宠》...
- html的size属性,HTML size属性用法及代码示例
- linux -m32,32位gcc和64位gcc与-m32选项有什么区别?
- 全球与中国石材加工机械市场现状及未来发展趋势
热门文章
- css 实现章节名称不换行,多余部分用 ... 代替
- 一键将Python2代码自动转化为Python3
- Android之android studio如何把项目分享到github并提修改的代码到Github
- 3分钟搞定 C++ if else 语句 05
- [python opencv 计算机视觉零基础到实战] 十一找到图片中指定内容
- 编写函数判断一个数是否是回文数_程序员面试金典 - 面试题 01.04. 回文排列
- python为text添加滚动条_在Tkinter中向一组小部件添加滚动条
- mathwin.top 联系我们_设计:“有目的”的“因果联系”
- 打得了橄榄球大联盟,进得了麻省理工,无论是四肢还是头脑都同样发达,这才叫猛男!...
- 中国人数学好,数学思维差?