thymeleaf的具体语法
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                thymeleaf的具体语法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.                        
                                thymeleaf模板引擎是什么?請點擊我查看
文章目錄
- thymeleaf模板引擎是什么?請點擊我查看
- 代碼延續(xù)[thymeleaf模板引擎](https://blog.csdn.net/Kevinnsm/article/details/111357103)
 
- 一、語法一
- 二、修改success.html中的內(nèi)容
- 總結(jié)
代碼延續(xù)thymeleaf模板引擎
提示:以下是本篇文章正文內(nèi)容,下面案例可供參考
一、語法一
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里面的內(nèi)容設(shè)置為我們指定的值--><div th:text="${hao}">請輸入text</div> </body> </html>4.啟動訪問http://localhost:8080/success,如下圖所示
 
 5.查看源代碼
 
 我們發(fā)現(xiàn)已經(jīng)將標簽體中的內(nèi)容覆蓋了
二、修改success.html中的內(nèi)容
<!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里面的內(nèi)容設(shè)置為我們指定的值--><div id="div1" class="class1" th:id="${hao}" th:class="${hao}" th:text="${hao}">輸入</div> <!--語法--> </body> </html>再次運行
 訪問localhost:8080/success,查看源代碼
 
 自此我們就知道th的作用了
總結(jié)
其他具體請查看thymeleaf文檔
總結(jié)
以上是生活随笔為你收集整理的thymeleaf的具体语法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: thymeleaf模板引擎
- 下一篇: 实现WebMvcConfigurer接口
