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.字 ...
随机推荐
- 高颜值测试报告- XTestRunner
Modern style test report based on unittest framework. 基于unittest框架现代风格测试报告. 特点 漂亮测试报告让你更愿意编写测试. 支持单元 ...
- 闲聊系列之 5-why root cause分析法
本篇参考: https://max.book118.com/html/2017/1126/141669829.shtm https://baike.baidu.com/item/5why%E5%88% ...
- python 生产数据表脚本
# -*- coding: utf-8 -*-import re"""建立相关表的字段从源表创建指定的MySQL建表脚本"""# 目标表名称 ...
- 实践:Linux下安装mysql8.0
镜像下载.域名解析.时间同步请点击 阿里云开源镜像站 一.下载mysql8.0安装包 1.在local创建mysql文件夹 cd /usr/local mkdir mysql cd mysql 2.使 ...
- 老徐和阿珍的故事:Runnable和Callable有什么不同?
人物背景: 老徐,男,本名徐福贵,从事Java相关研发工作多年,职场老油条,摸鱼小能手,虽然岁数不大但长的比较着急,人称老徐.据说之前炒某币败光了所有家产,甚至现在还有欠债. 阿珍,女,本名陈家珍,刚 ...
- BLHeli/ BLHeli_S开源无刷电调学习记录
BLHeli的历史轨迹:BLHeli -> BLHeli_S -> BLHeli_32,我们重点学习BLHeli_S版本. 该代码支持常规的1-2ms脉冲宽度输入,以及Oneshot125 ...
- 通常一个 Xml 映射文件,都会写一个 Dao 接口与之对应, 请问,这个 Dao 接口的工作原理是什么?Dao 接口里的方法, 参数不同时,方法能重载吗?
Dao 接口即 Mapper 接口.接口的全限名,就是映射文件中的 namespace 的值: 接口的方法名,就是映射文件中 Mapper 的 Statement 的 id 值:接口方法内的 参数,就 ...
- C printf格式化输出
转载:https://blog.csdn.net/wucz122140729/article/details/98434702 格式化输出 格式化输出的函数有printf.sprintf和 ...
- 数据库MySql的学习(1)--基本操作
转自 博客园-hoojo-http://www.cnblogs.com/hoojo/archive/2011/06/20/2085390.html 一.数据库简单介绍 1. 按照数据库的发展时间顺序, ...
- 什么是 Ribbon负载均衡?
(1)Spring Cloud Ribbon是基于Netflix Ribbon实现的一套客户端 负载均衡的工具. (2)Ribbon客户端组件提供一系列完善的配置项如连接超时,重试等.简单的说,就是在配 ...