thymeleaf的具体语法
thymeleaf模板引擎是什么?请点击我查看
文章目录
代码
该实例代码延续thymeleaf模板引擎
提示:以下是本篇文章正文内容,下面案例可供参考
一、语法一
1.首先引入约束
<html lang="en" xmlns:th="http://www.thymeleaf.org">
2.Controller书写
@Controller
public class HelloController {
@RequestMapping("/success")
public String success(Map<String,Object> map){
map.put("hao","真棒!");
return "success";
}
}
3.success.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>success</title>
</head>
<body>
<h1>成功!</h1>
<!-- th:text 将div里面的内容设置为我们指定的值-->
<div th:text="${hao}">请输入text</div>
</body>
</html>
4.启动访问http://localhost:8080/success,如下图所示

5.查看源代码

我们发现已经将标签体中的内容覆盖了
二、修改success.html中的内容
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>success</title>
</head>
<body>
<h1>成功!</h1>
<!-- th:text 将div里面的内容设置为我们指定的值-->
<div id="div1" class="class1" th:id="${hao}" th:class="${hao}" th:text="${hao}">输入</div>
<!--语法-->
</body>
</html>
再次运行
访问localhost:8080/success,查看源代码

自此我们就知道th的作用了
总结
其他具体请查看thymeleaf文档
thymeleaf的具体语法的更多相关文章
- thymeleaf 内联语法
十二. thymeleaf内联语法 内联:th:inline,值有三种:text,javascript,none 12.1 th:inline="text"文本内联 <p t ...
- Thymeleaf的基本语法总结
最近用Spring boot开发一些测试平台和工具,用到页面展示的部分, 选择的是thymeleaf模版引擎. 页面开发的7788快结束了,下面来总结下此过程中对thymeleaf的使用总结. 什么是 ...
- Thymeleaf 2-基础语法
三.基础语法 1.创建HTML 由上文也可以知道需要在html中添加: <html xmlns:th="http://www.thymeleaf.org"> 这样,下文 ...
- Thymeleaf 标准表达式语法
变量表达式${ } 在控制器中往页面传递几个变量: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 @Controller public class IndexController ...
- Thymeleaf模板引擎语法
th:text 用于显示值 th:object 接收后台传来的对象 th:action 提交表单 th:value 绑定值 th:field 绑定 ...
- Spring Boot整合Thymeleaf及Thymeleaf页面基本语法
引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp ...
- thymeleaf 基本语法
四.标准表达式语法 · 简单表达式 (simple expressions) ${...} 变量表达式 *{...} 选择变量表达式 #{...} 消息表达式 @{...} 链接url表达式 ...
- Thymeleaf系列五 迭代,if,switch语法
1. 概述 这里介绍thymeleaf的编程语法,本节主要包括如下内容 迭代语法:th:each; iteration status 条件语法:th:if; th:unless switch语法: ...
- thymeleaf 语法
一.语法: 1. 简单表达式 (simple expressions) ${...} 变量表达式 *{...} 选择变量表达式 #{...} 消息表达式 @{...} 链接url表达式 2.字 ...
随机推荐
- NTFS权限概述
NTFS权限概述 NTFS是我常见的一种磁盘格式,在Windows系统中使用广泛,它打破了FAT的局限性.在我使用ntfs格式分区的时候经常会涉及到ntfs权限设置问题,来帮助我们对文件的处理.那么什 ...
- joblib保存模型和joblib的并行化处理和tqdm
keep首先是默认first
- 如何解决代码中if/else 过多的问题
前言 if...else 是所有高级编程语言都有的必备功能.但现实中的代码往往存在着过多的 if...else.虽然 if...else 是必须的,但滥用 if...else 会对代码的可读性.可维护 ...
- TypeScript 初体验
TypeScript学习 1 安装环境 a 首先安装node.js node.js 用来将ts文件解析成js文件 供浏览器使用: 解析ts文件 tsc filename.ts b. 使用npm (no ...
- 『忘了再学』Shell基础 — 3、echo命令的介绍与使用
目录 1.echo命令的作用 2.echo命令的基本用法 3.echo命令的-e选项用法 4.echo命令一些特殊用法 (1)输出字符带有字体颜色 (2)输出字符带有背景颜色 在讲Shell脚本之前, ...
- 在Windows11使用WSA运行Google play会遇到的问题
前提一是要有adb工具 网盘链接:https://pan.baidu.com/s/1MAdq4GsxkW7dqq689d_gQw 提取码:24q2 前提二是会使用 MagiskOnWSA--解决了两个 ...
- Kafka03--Kafka消费者使用方式
前言 与生产者客户端一样,消费者端也由最初的scala版本过渡到现在的Java版本. 正常的消费者逻辑需要以下4个步骤: KafkaConsumer的客户端参数配置和对应实例: 订阅主题 拉取消息并消 ...
- volatile 有什么用?能否用一句话说明下 volatile 的应用场景?
volatile 保证内存可见性和禁止指令重排. volatile 用于多线程环境下的单次操作(单次读或者单次写).
- 面试问题之计算机网络:HTTP和HTTPS的区别
https://blog.csdn.net/qq_38289815/article/details/80969419
- SpringBoot单元测试携带Cookie
由于我SpringBoot项目,集成了SpringSecurity,而Security框架使用Redis存储Session,所以,这里列出几个关键的类 org.springframework.sess ...