标签:属性 path nat gif frame boot d3d 集成 ESS
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-thymeleaf</artifactId> 4 </dependency>
1 package com.atguigu.controller; 2 3 import org.springframework.stereotype.Controller; 4 import org.springframework.web.bind.annotation.RequestMapping; 5 6 import java.util.Map; 7 8 @Controller 9 public class HelloController { 10 11 @RequestMapping("/hello") 12 public String sayHello(Map<String,Object> map){ 13 map.put("name","hmz"); 14 return "success"; 15 } 16 17 }
1 xmlns:th="http://www.thymeleaf.org"
1 <!DOCTYPE html> 2 <html lang="en" xmlns:th="http://www.thymeleaf.org"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>thymeleaf</title> 6 </head> 7 <body> 8 <h1>Hello World!</h1> 9 <div th:text="${name}">这里显示欢迎信息</div> 10 </body> 11 </html>
1 <html xmlns:th="http://www.thymeleaf.org">
1 <div th:text="${hello}"></div>
<div th:object="${session.user}"> <p>Name: <span th:text="*{firstName}">Sebastian</span>.</p> <p>Surname: <span th:text="*{lastName}">Pepper</span>.</p> <p>Nationality: <span th:text={nationality}">Saturn</span>.</p> </div> 等价于 <div> <p>Name: <span th:text="${session.user.firstName}">Sebastian</span>.</p> <p>Surname: <span th:text="${session.user.lastName}">Pepper</span>.</p> <p>Nationality: <span th:text="${session.user.nationality}">Saturn</span>.</p> </div>
1 <a href="details.html" th:href="@{http://localhost:8080/gtvg/order/details(orderId=${o.id})}">view</a> <!-- Will produce ‘/gtvg/order/details?orderId=3‘ (plus rewriting) -->
标签:属性 path nat gif frame boot d3d 集成 ESS
原文地址:https://www.cnblogs.com/HNewa/p/Spring_Boot_thymeleaf.html