Browse Source

update thymeleaf to 4.0

纯洁的微笑 6 years ago
parent
commit
e6ceae590e
33 changed files with 576 additions and 81 deletions
  1. 0 35
      spring-boot-thymeleaf/pom.xml
  2. 66 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/pom.xml
  3. 13 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/TLayoutApplication.java
  4. 31 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/web/IndexController.java
  5. 2 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/application.properties
  6. 15 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/base.html
  7. 11 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/fragment.html
  8. 11 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/home.html
  9. 11 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/index.html
  10. 15 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout.html
  11. 12 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/copyright.html
  12. 12 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/footer.html
  13. 12 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/header.html
  14. 12 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/left.html
  15. 16 0
      spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/test/java/com/neo/TLayoutApplicationTests.java
  16. 62 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/pom.xml
  17. 13 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/ThymeleafApplication.java
  18. 49 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/model/User.java
  19. 66 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/ExampleController.java
  20. 16 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/HelloController.java
  21. 1 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/application.properties
  22. 17 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/eq.html
  23. 10 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/hello.html
  24. 15 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/if.html
  25. 20 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/list.html
  26. 16 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/string.html
  27. 17 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/switch.html
  28. 19 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/url.html
  29. 16 0
      spring-boot-thymeleaf/spring-boot-thymeleaf/src/test/java/com/neo/ThymeleafApplicationTests.java
  30. 0 15
      spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/HelloController.java
  31. 0 20
      spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/ThymeleafApplication.java
  32. 0 1
      spring-boot-thymeleaf/src/main/resources/application.properties
  33. 0 10
      spring-boot-thymeleaf/src/main/resources/templates/hello.html

+ 0 - 35
spring-boot-thymeleaf/pom.xml

@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>spring-boot-thymeleaf</artifactId>
-    <name>spring-boot-thymeleaf</name>
-    <description>spring-boot-thymeleaf</description>
-    <parent>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.5.6.RELEASE</version>
-    </parent>
-
-    <properties>
-        <java.version>1.8</java.version>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-thymeleaf</artifactId>
-        </dependency>
-    </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-</project>

+ 66 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/pom.xml

@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>com.neo</groupId>
+	<artifactId>spring-boot-thymeleaf-layout</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>spring-boot-thymeleaf-layout</name>
+	<description>Demo project for Spring Boot</description>
+
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.1.0.RELEASE</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+		<java.version>1.8</java.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-thymeleaf</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>nz.net.ultraq.thymeleaf</groupId>
+			<artifactId>thymeleaf-layout-dialect</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-devtools</artifactId>
+			<scope>runtime</scope>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+					<fork>true</fork>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+
+</project>

+ 13 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/TLayoutApplication.java

@@ -0,0 +1,13 @@
+package com.neo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class TLayoutApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(TLayoutApplication.class, args);
+	}
+
+}

+ 31 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/web/IndexController.java

@@ -0,0 +1,31 @@
+package com.neo.web;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Controller
+public class IndexController {
+
+    @RequestMapping("/index")
+    public String index() {
+        return "index";
+    }
+
+    @RequestMapping("/fragment")
+    public String fragment() {
+        return "fragment";
+    }
+
+    @RequestMapping("/layout")
+    public String layout() {
+        return "layout";
+    }
+
+    @RequestMapping("/home")
+    public String home() {
+        return "home";
+    }
+
+
+}

+ 2 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/application.properties

@@ -0,0 +1,2 @@
+com.neo.title=\u7EAF\u6D01\u7684\u5FAE\u7B11
+com.neo.description=\u5206\u4EAB\u751F\u6D3B\u548C\u6280\u672F

+ 15 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/base.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:fragment="common_header(title,links)">
+    <title th:replace="${title}">comm title</title>
+
+    <link rel="stylesheet" type="text/css" media="all" th:href="@{/css/myapp.css}">
+    <link rel="shortcut icon" th:href="@{/images/favicon.ico}">
+    <script type="text/javascript" th:src="@{/js/myapp.js}"></script>
+
+    <th:block th:replace="${links}" />
+</head>
+<body>
+
+</body>
+</html>

+ 11 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/fragment.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="base :: common_header(~{::title},~{::link})">
+    <title>Fragment - Page</title>
+    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
+    <link rel="stylesheet" th:href="@{/cs/fragment.css}">
+</head>
+<body>
+
+</body>
+</html>

+ 11 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/home.html

@@ -0,0 +1,11 @@
+<html xmlns:th="http://www.thymeleaf.org"  xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorate="layout">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Home</title>
+</head>
+<body>
+    <div  layout:fragment="content" >
+        <h2>个性化的内容</h2>
+    </div>
+</body>
+</html>

+ 11 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/index.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Index</title>
+</head>
+<body>
+    <div th:insert="layout/copyright :: copyright"></div>
+    <div th:replace="layout/copyright :: copyright"></div>
+</body>
+</html>

+ 15 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Layout</title>
+</head>
+<body>
+<div >
+    <div th:replace="layout/header :: header"></div>
+    <div th:replace="layout/left :: left"></div>
+    <div layout:fragment="content" > content</div>
+    <div th:replace="layout/footer :: footer"></div>
+</div>
+</body>
+</html>

+ 12 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/copyright.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Title</title>
+</head>
+<body>
+<copyright th:fragment="copyright">
+    &copy; 2018
+</copyright>
+</body>
+</html>

+ 12 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/footer.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>footer</title>
+</head>
+<body>
+<footer th:fragment="footer">
+    <h1>我是 尾部</h1>
+</footer>
+</body>
+</html>

+ 12 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/header.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>header</title>
+</head>
+<body>
+<header th:fragment="header">
+    <h1>我是 头部</h1>
+</header>
+</body>
+</html>

+ 12 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/left.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>left</title>
+</head>
+<body>
+<left th:fragment="left">
+    <h1>我是 左侧</h1>
+</left>
+</body>
+</html>

+ 16 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/test/java/com/neo/TLayoutApplicationTests.java

@@ -0,0 +1,16 @@
+package com.neo;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class TLayoutApplicationTests {
+
+	@Test
+	public void contextLoads() {
+	}
+
+}

+ 62 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/pom.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>com.neo</groupId>
+	<artifactId>spring-boot-thymeleaf</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>spring-boot-thymeleaf</name>
+	<description>Demo project for Spring Boot</description>
+
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.1.0.RELEASE</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+		<java.version>1.8</java.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-thymeleaf</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-devtools</artifactId>
+			<scope>runtime</scope>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+					<fork>true</fork>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+
+</project>

+ 13 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/ThymeleafApplication.java

@@ -0,0 +1,13 @@
+package com.neo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ThymeleafApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(ThymeleafApplication.class, args);
+	}
+
+}

+ 49 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/model/User.java

@@ -0,0 +1,49 @@
+package com.neo.model;
+
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Size;
+
+public class User {
+    private String name;
+    private int age;
+    private String pass;
+
+    public User(String name, int age, String pass) {
+        this.name = name;
+        this.age = age;
+        this.pass = pass;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public String getPass() {
+        return pass;
+    }
+
+    public void setPass(String pass) {
+        this.pass = pass;
+    }
+
+    @Override
+    public String toString() {
+        return ("name=" + this.name + ",age=" + this.age + ",pass=" + this.pass);
+    }
+}

+ 66 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/ExampleController.java

@@ -0,0 +1,66 @@
+package com.neo.web;
+
+import com.neo.model.User;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Controller
+public class ExampleController {
+
+    @RequestMapping("/string")
+    public String string(ModelMap map) {
+        map.addAttribute("userName", "ityouknow");
+        return "string";
+    }
+
+    @RequestMapping("/if")
+    public String ifunless(ModelMap map) {
+        map.addAttribute("flag", "yes");
+        return "if";
+    }
+
+    @RequestMapping("/list")
+    public String list(ModelMap map) {
+        map.addAttribute("users", getUserList());
+        return "list";
+    }
+
+    @RequestMapping("/url")
+    public String url(ModelMap map) {
+        map.addAttribute("type", "link");
+        map.addAttribute("pageId", "springcloud/2017/09/11/");
+        map.addAttribute("img", "http://www.ityouknow.com/assets/images/neo.jpg");
+        return "url";
+    }
+
+    @RequestMapping("/eq")
+    public String eq(ModelMap map) {
+        map.addAttribute("name", "neo");
+        map.addAttribute("age", 30);
+        map.addAttribute("flag", "yes");
+        return "eq";
+    }
+
+    @RequestMapping("/switch")
+    public String switchcase(ModelMap map) {
+        map.addAttribute("sex", "woman");
+        return "switch";
+    }
+
+    private List<User> getUserList(){
+        List<User> list=new ArrayList<User>();
+        User user1=new User("大牛",12,"123456");
+        User user2=new User("小牛",6,"123563");
+        User user3=new User("纯洁的微笑",66,"666666");
+        list.add(user1);
+        list.add(user2);
+        list.add(user3);
+        return  list;
+    }
+
+}

+ 16 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/HelloController.java

@@ -0,0 +1,16 @@
+package com.neo.web;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Controller
+public class HelloController {
+
+    @RequestMapping("/")
+    public String index(ModelMap map) {
+        map.addAttribute("message", "http://www.ityouknow.com");
+        return "hello";
+    }
+
+}

+ 1 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/application.properties

@@ -0,0 +1 @@
+spring.thymeleaf.cache=false

+ 17 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/eq.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Example gt eq  </title>
+</head>
+<body>
+<div >
+    <h1>EQ</h1>
+    <input th:value="${name}"/>
+    <br/>
+    <input th:value="${age gt 30 ? '中年':'年轻'}"/>
+    <br/>
+    <a th:if="${flag eq 'yes'}"  th:href="@{http://favorites.ren/}"> favorites </a>
+</div>
+</body>
+</html>

+ 10 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/hello.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Hello</title>
+</head>
+<body>
+<h1  th:text="${message}">Hello World</h1>
+</body>
+</html>

+ 15 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/if.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Example If/Unless </title>
+</head>
+<body>
+<div >
+    <h1>If/Unless</h1>
+    <a th:if="${flag == 'yes'}"  th:href="@{http://favorites.ren/}"> home </a>
+    <br/>
+    <a th:unless="${flag != 'no'}" th:href="@{http://www.ityouknow.com/}" >ityouknow</a>
+</div>
+</body>
+</html>

+ 20 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/list.html

@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Example If/Unless </title>
+</head>
+<body>
+<div >
+    <h1>for 循环</h1>
+    <table>
+        <tr  th:each="user,iterStat : ${users}">
+            <td th:text="${user.name}">neo</td>
+            <td th:text="${user.age}">6</td>
+            <td th:text="${user.pass}">213</td>
+            <td th:text="${iterStat.index}">index</td>
+        </tr>
+    </table>
+</div>
+</body>
+</html>

+ 16 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/string.html

@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Example String </title>
+</head>
+<body>
+    <div >
+        <h1>text</h1>
+        <p th:text="${userName}">neo</p>
+        <span th:text="'Welcome to our application, ' + ${userName} + '!'"></span>
+        <br/>
+        <span th:text="|Welcome to our application, ${userName}!|"></span>
+    </div>
+</body>
+</html>

+ 17 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/switch.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Example switch </title>
+</head>
+<body>
+<div >
+    <div th:switch="${sex}">
+        <p th:case="'woman'">她是一个姑娘...</p>
+        <p th:case="'man'">这是一个爷们!</p>
+        <!-- *: case的默认的选项 -->
+        <p th:case="*">未知性别的一个家伙。</p>
+    </div>
+</div>
+</body>
+</html>

+ 19 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/url.html

@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="en"  xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"></meta>
+    <title>Example If/Unless </title>
+</head>
+<body>
+<div >
+    <h1>URL</h1>
+    <a  th:href="@{http://www.ityouknow.com/{type}(type=${type})}">link1</a>
+    <br/>
+    <a th:href="@{http://www.ityouknow.com/{pageId}/can-use-springcloud.html(pageId=${pageId})}">view</a>
+    <br/>
+    <div th:style="'background:url(' + @{${img}} + ');'">
+        <br/><br/><br/>
+    </div>
+</div>
+</body>
+</html>

+ 16 - 0
spring-boot-thymeleaf/spring-boot-thymeleaf/src/test/java/com/neo/ThymeleafApplicationTests.java

@@ -0,0 +1,16 @@
+package com.neo;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class ThymeleafApplicationTests {
+
+	@Test
+	public void contextLoads() {
+	}
+
+}

+ 0 - 15
spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/HelloController.java

@@ -1,15 +0,0 @@
-package com.neo.thymeleaf;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@Controller
-public class HelloController {
-    @RequestMapping("/hello")
-    public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) {
-        model.addAttribute("name", name);
-        return "hello";
-    }
-}

+ 0 - 20
spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/ThymeleafApplication.java

@@ -1,20 +0,0 @@
-package com.neo.thymeleaf;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
-
-
-@SpringBootApplication
-public class ThymeleafApplication extends SpringBootServletInitializer {
-    @Override
-    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
-        return application.sources(ThymeleafApplication.class);
-    }
-
-    public static void main(String[] args) throws Exception {
-        SpringApplication.run(ThymeleafApplication.class, args);
-    }
-}
-

+ 0 - 1
spring-boot-thymeleaf/src/main/resources/application.properties

@@ -1 +0,0 @@
-spring.thymeleaf.cache: false

+ 0 - 10
spring-boot-thymeleaf/src/main/resources/templates/hello.html

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org">
-<head>
-    <meta charset="UTF-8"/>
-    <title>Hello Thymeleaf!</title>
-</head>
-<body>
-    <p th:text="'Hello, ' + ${name} + '!'" />
-</body>
-</html>