diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/pom.xml b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/pom.xml new file mode 100644 index 0000000..6677f52 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + com.neo + spring-boot-thymeleaf-layout + 0.0.1-SNAPSHOT + jar + + spring-boot-thymeleaf-layout + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 3.0.0 + + + + + UTF-8 + 17 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + nz.net.ultraq.thymeleaf + thymeleaf-layout-dialect + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + + diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/TLayoutApplication.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/TLayoutApplication.java new file mode 100644 index 0000000..0e4e29a --- /dev/null +++ b/3.x/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); + } + +} diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/web/IndexController.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/java/com/neo/web/IndexController.java new file mode 100644 index 0000000..3b25541 --- /dev/null +++ b/3.x/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"; + } + + +} \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/application.properties b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/application.properties new file mode 100644 index 0000000..975a517 --- /dev/null +++ b/3.x/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 \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/base.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/base.html new file mode 100644 index 0000000..6a49119 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/base.html @@ -0,0 +1,15 @@ + + + + comm title + + + + + + + + + + + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/fragment.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/fragment.html new file mode 100644 index 0000000..bb65abe --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/fragment.html @@ -0,0 +1,11 @@ + + + + Fragment - Page + + + + + + + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/home.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/home.html new file mode 100644 index 0000000..bd0de80 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/home.html @@ -0,0 +1,11 @@ + + + + Home + + +
+

个性化的内容

+
+ + diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/index.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/index.html new file mode 100644 index 0000000..40d3657 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/index.html @@ -0,0 +1,11 @@ + + + + + Index + + +
+
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout.html new file mode 100644 index 0000000..4bc09f3 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout.html @@ -0,0 +1,15 @@ + + + + + Layout + + +
+
+
+
content
+
+
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/copyright.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/copyright.html new file mode 100644 index 0000000..223de9f --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/copyright.html @@ -0,0 +1,12 @@ + + + + + Title + + + + © 2018 + + + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/footer.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/footer.html new file mode 100644 index 0000000..48a9c7d --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/footer.html @@ -0,0 +1,12 @@ + + + + + footer + + + + + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/header.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/header.html new file mode 100644 index 0000000..adc6b8c --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/header.html @@ -0,0 +1,12 @@ + + + + + header + + +
+

我是 头部

+
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/left.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/left.html new file mode 100644 index 0000000..04d8875 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/main/resources/templates/layout/left.html @@ -0,0 +1,12 @@ + + + + + left + + + +

我是 左侧

+
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/test/java/com/neo/TLayoutApplicationTests.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf-layout/src/test/java/com/neo/TLayoutApplicationTests.java new file mode 100644 index 0000000..3e1b0ab --- /dev/null +++ b/3.x/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() { + } + +} diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/pom.xml b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/pom.xml new file mode 100644 index 0000000..03aea7c --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + com.neo + spring-boot-thymeleaf + 0.0.1-SNAPSHOT + jar + + spring-boot-thymeleaf + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 3.0.0 + + + + + UTF-8 + 17 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/ThymeleafApplication.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/ThymeleafApplication.java new file mode 100644 index 0000000..e194e86 --- /dev/null +++ b/3.x/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); + } + +} diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/model/User.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/model/User.java new file mode 100644 index 0000000..55fabd5 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/model/User.java @@ -0,0 +1,44 @@ +package com.neo.model; + + + +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); + } +} diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/ExampleController.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/ExampleController.java new file mode 100644 index 0000000..1127603 --- /dev/null +++ b/3.x/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 getUserList(){ + List list=new ArrayList(); + 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; + } + +} \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/HelloController.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/java/com/neo/web/HelloController.java new file mode 100644 index 0000000..2eac4e8 --- /dev/null +++ b/3.x/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"; + } + +} \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/application.properties b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/application.properties new file mode 100644 index 0000000..4b9333a --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.thymeleaf.cache=false \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/eq.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/eq.html new file mode 100644 index 0000000..70e65a9 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/eq.html @@ -0,0 +1,17 @@ + + + + + Example gt eq + + +
+

EQ

+ +
+ +
+ favorites +
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/hello.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/hello.html new file mode 100644 index 0000000..28c5116 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/hello.html @@ -0,0 +1,10 @@ + + + + + Hello + + +

Hello World

+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/if.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/if.html new file mode 100644 index 0000000..9127c23 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/if.html @@ -0,0 +1,15 @@ + + + + + Example If/Unless + + +
+

If/Unless

+ home +
+ ityouknow +
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/list.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/list.html new file mode 100644 index 0000000..017c65e --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/list.html @@ -0,0 +1,20 @@ + + + + + Example If/Unless + + +
+

for 循环

+ + + + + + + +
neo6213index
+
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/string.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/string.html new file mode 100644 index 0000000..7a2e3f6 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/string.html @@ -0,0 +1,16 @@ + + + + + Example String + + +
+

text

+

neo

+ +
+ +
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/switch.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/switch.html new file mode 100644 index 0000000..aef5a30 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/switch.html @@ -0,0 +1,17 @@ + + + + + Example switch + + +
+
+

她是一个姑娘...

+

这是一个爷们!

+ +

未知性别的一个家伙。

+
+
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/url.html b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/url.html new file mode 100644 index 0000000..ded5268 --- /dev/null +++ b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/main/resources/templates/url.html @@ -0,0 +1,19 @@ + + + + + Example If/Unless + + +
+

URL

+ link1 +
+ view +
+
+


+
+
+ + \ No newline at end of file diff --git a/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/test/java/com/neo/ThymeleafApplicationTests.java b/3.x/spring-boot-thymeleaf/spring-boot-thymeleaf/src/test/java/com/neo/ThymeleafApplicationTests.java new file mode 100644 index 0000000..3ccf7f4 --- /dev/null +++ b/3.x/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() { + } + +} diff --git a/README.md b/README.md index 7fc1a3c..641c5a6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Spring Boot 使用的各种示例,以最简单、最实用为标准,此开 - [spring-boot-helloworld](https://github.com/ityouknow/spring-boot-examples/tree/master/3.x/spring-boot-helloWorld):Spring Boot 3.0 Hello World Test 单元测试示例 - [spring-boot-web](https://github.com/ityouknow/spring-boot-examples/tree/master/3.x/spring-boot-web):Spring Boot 3.0 web 示例 - [spring-boot-redis](https://github.com/ityouknow/spring-boot-examples/tree/master/3.x/spring-boot-redis):Spring Boot 3.0 Redis 示例 - +- [spring-boot-thymeleaf](https://github.com/ityouknow/spring-boot-examples/tree/master/3.x/spring-boot-thymeleaf):Spring Boot 3.0 Thymeleaf 示例 ---