當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
[SpringBoot2]Thymeleaf
生活随笔
收集整理的這篇文章主要介紹了
[SpringBoot2]Thymeleaf
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
- 引入starter
- 自動配置好了thymeleaf
自動配好的策略
● 1、所有thymeleaf的配置值都在 ThymeleafProperties
● 2、配置好了 SpringTemplateEngine
● 3、配好了 ThymeleafViewResolver
● 4、我們只需要直接開發頁面
- 名稱空間
測試:
<!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]@Matrix
- 下一篇: 如何测试线路板阻抗阻抗电脑如何测