From b254a27a7f24fc2aede3b300f52318fd5fc2c8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=AF=E6=B4=81=E7=9A=84=E5=BE=AE=E7=AC=91?= Date: Tue, 12 Sep 2017 20:13:00 +0800 Subject: [PATCH] add spring-boot-thymeleaf --- README.md | 1 + README_EN.md | 1 + spring-boot-thymeleaf/pom.xml | 35 +++++++++++++++++++ .../com/neo/thymeleaf/HelloController.java | 15 ++++++++ .../neo/thymeleaf/ThymeleafApplication.java | 20 +++++++++++ .../src/main/resources/application.properties | 1 + .../src/main/resources/templates/hello.html | 10 ++++++ 7 files changed, 83 insertions(+) create mode 100644 spring-boot-thymeleaf/pom.xml create mode 100644 spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/HelloController.java create mode 100644 spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/ThymeleafApplication.java create mode 100644 spring-boot-thymeleaf/src/main/resources/application.properties create mode 100644 spring-boot-thymeleaf/src/main/resources/templates/hello.html diff --git a/README.md b/README.md index 362a6c7..d3ea37e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Spring boot使用的各种示例,以最简单、最实用为标准 - [spring-boot-multi-mongodb](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-multi-mongodb):spring boot和mongodb多数据源的使用 - [spring-boot-package-war](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-package-war):spring-boot打包成war包示例 - [spring-boot-shiro](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-shiro):springboot 整合shiro rbac示例 +- [spring-boot-thymeleaf](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-thymeleaf):简单 spring boot thymeleaf 脚手架 - [Favorites-web](https://github.com/cloudfavorites/favorites-web):云收藏(springboot实战开源软件) diff --git a/README_EN.md b/README_EN.md index 96f4ae9..9fa13c2 100644 --- a/README_EN.md +++ b/README_EN.md @@ -22,4 +22,5 @@ Spring Boot Examples, Use the simplest and most useful scene demo. - [spring-boot-multi-mongodb](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-multi-mongodb):Spring Boot + multiMongodb - [spring-boot-package-war](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-package-war):Spring Boot package war - [spring-boot-shiro](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-shiro):spring boot shiro rbac demo +- [spring-boot-thymeleaf](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-thymeleaf):simple spring boot thymeleaf demo - [Favorites-web](https://github.com/cloudfavorites/favorites-web):Open source projects developed using Spring Boot diff --git a/spring-boot-thymeleaf/pom.xml b/spring-boot-thymeleaf/pom.xml new file mode 100644 index 0000000..2547f81 --- /dev/null +++ b/spring-boot-thymeleaf/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + spring-boot-thymeleaf + spring-boot-thymeleaf + spring-boot-thymeleaf + + org.springframework.boot + spring-boot-starter-parent + 1.5.6.RELEASE + + + + 1.7 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/HelloController.java b/spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/HelloController.java new file mode 100644 index 0000000..9251d84 --- /dev/null +++ b/spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/HelloController.java @@ -0,0 +1,15 @@ +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"; + } +} diff --git a/spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/ThymeleafApplication.java b/spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/ThymeleafApplication.java new file mode 100644 index 0000000..cd468c3 --- /dev/null +++ b/spring-boot-thymeleaf/src/main/java/com/neo/thymeleaf/ThymeleafApplication.java @@ -0,0 +1,20 @@ +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); + } +} + diff --git a/spring-boot-thymeleaf/src/main/resources/application.properties b/spring-boot-thymeleaf/src/main/resources/application.properties new file mode 100644 index 0000000..760bdc3 --- /dev/null +++ b/spring-boot-thymeleaf/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.thymeleaf.cache: false \ No newline at end of file diff --git a/spring-boot-thymeleaf/src/main/resources/templates/hello.html b/spring-boot-thymeleaf/src/main/resources/templates/hello.html new file mode 100644 index 0000000..bd1f781 --- /dev/null +++ b/spring-boot-thymeleaf/src/main/resources/templates/hello.html @@ -0,0 +1,10 @@ + + + + + Hello Thymeleaf! + + +

+ + \ No newline at end of file -- GitLab