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的具体语法的更多相关文章

  1. thymeleaf 内联语法

    十二. thymeleaf内联语法 内联:th:inline,值有三种:text,javascript,none 12.1 th:inline="text"文本内联 <p t ...

  2. Thymeleaf的基本语法总结

    最近用Spring boot开发一些测试平台和工具,用到页面展示的部分, 选择的是thymeleaf模版引擎. 页面开发的7788快结束了,下面来总结下此过程中对thymeleaf的使用总结. 什么是 ...

  3. Thymeleaf 2-基础语法

    三.基础语法 1.创建HTML 由上文也可以知道需要在html中添加: <html xmlns:th="http://www.thymeleaf.org"> 这样,下文 ...

  4. Thymeleaf 标准表达式语法

    变量表达式${ } 在控制器中往页面传递几个变量: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 @Controller public class IndexController ...

  5. Thymeleaf模板引擎语法

    th:text    用于显示值 th:object      接收后台传来的对象 th:action      提交表单 th:value       绑定值 th:field         绑定 ...

  6. Spring Boot整合Thymeleaf及Thymeleaf页面基本语法

    引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sp ...

  7. thymeleaf 基本语法

    四.标准表达式语法 · 简单表达式 (simple expressions) ${...}  变量表达式 *{...}  选择变量表达式 #{...}  消息表达式 @{...}  链接url表达式 ...

  8. Thymeleaf系列五 迭代,if,switch语法

      1. 概述 这里介绍thymeleaf的编程语法,本节主要包括如下内容 迭代语法:th:each; iteration status 条件语法:th:if; th:unless switch语法: ...

  9. thymeleaf 语法

    一.语法: 1. 简单表达式 (simple expressions) ${...}  变量表达式 *{...}  选择变量表达式 #{...}  消息表达式 @{...}  链接url表达式 2.字 ...

随机推荐

  1. linux下编译安装php5.6出现 configure: error: Cannot find MySQL header files under /usr/local/mysql.

    #yum install gcc gcc-c++ libxml2 libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-dev ...

  2. OSPF协议原理及配置2-理解邻居和邻接关系

    OSPF是一个动态路由协议,运行OSPF的路由器之间需要交换链路状态信息和路由信息,在交换这些信息之前首先需要建立邻接关系.邻接关系用来交换链路状态及路由信息. 注意:并非所有的邻居关系都可以成为邻接 ...

  3. Kubernetes系列(四) StatefulSet

    作者: LemonNan 原文地址: https://juejin.im/post/6870071267438329869 Kubernetes系列(四) StatefulSet Kubernetes ...

  4. 使用ABP SignalR重构消息服务(一)

    使用ABP SignalR重构消息服务 最近协助蟹老板升级新框架,维护基础设施服务,目前已经稳了. 早上蟹老板看到我进入公司,马上就叫停我,说我为什么左脚先进公司,你这样会让我很难做耶,这样把我给你一 ...

  5. 『现学现忘』Docker基础 — 30、Docker中数据卷相关命令

    目录 1.Volume命令说明 2.Volume命令的使用 (1)创建数据卷 (2)查看本地数据卷列表 (3)打印myVolume数据卷的详细信息 (4)删除数据卷 (5)删除所有未使用的数据卷 3. ...

  6. 【混合编程】C/C++调用Fortran的DLL

    [混合编程]C/C++调用Fortran的DLL 以一个简单的加法器为例,介绍C/C++调用Fortran语言DLL的操作过程 一.Fortran操作 1.1 Fortran代码 首先是加法功能的实现 ...

  7. 5月7日 python学习总结 MySQL数据库(一)

    一.数据库介绍 1.数据库相关概念 数据库服务器(本质就是一台计算机,该计算机之上安装有数据库管理软件的服务端) 数据库管理系统RDBMS(本质就是一个C/S机构的套接字软件) 库(文件夹)===&g ...

  8. leetcode刷题1--动态规划法回文串2

    题目是: Given a string s,partition s such that every substring of the partition is a palindrome Return ...

  9. Captcha生成验证码,docker部署时问题

    https://blog.csdn.net/huofuman960209/article/details/100738712 Dockerfile FROM openjdk:8-jdk-alpine ...

  10. 对象头源码讲解,原来,指向objectMonitor的指针在这里

    markword 注释 该文件目录在: \openjdk-jdk8u\hotspot\src\share\vm\oops\markOop.hpp #ifndef SHARE_VM_OOPS_MARKO ...