From 236261536d75c1062950d8e54fb18eda2aace176 Mon Sep 17 00:00:00 2001 From: catalin-burcea Date: Wed, 30 Oct 2019 16:51:30 +0200 Subject: [PATCH] Split or move spring-thymeleaf module --- spring-thymeleaf-2/README.md | 10 ++++++++ spring-thymeleaf-2/pom.xml | 22 ++++++++++++++++++ .../arrays}/ThymeleafArrayController.java | 2 +- .../BooleanExpressionsController.java | 2 +- .../thymeleaf/customhtml}/Course.java | 2 +- .../CourseRegistrationController.java | 8 +++---- .../ParticipantController.java | 2 +- .../main/resources/templates}/booleans.html | 0 .../main/resources/templates/continents.html | 0 .../templates}/courseRegistration.html | 0 spring-thymeleaf/.gitignore | 1 - spring-thymeleaf/README.md | 6 ----- spring-thymeleaf/pom.xml | 21 ----------------- ...rkingWithArraysInThymeleafApplication.java | 12 ---------- .../src/main/webapp/WEB-INF/views/home.html | 3 --- .../SpringContextIntegrationTest.java | 13 +++++------ .../thymeleaf}/SpringContextTest.java | 13 +++++------ .../csrf/CsrfEnabledIntegrationTest.java | 23 +++++++++---------- 18 files changed, 62 insertions(+), 78 deletions(-) rename {spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller => spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays}/ThymeleafArrayController.java (92%) rename {spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller => spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions}/BooleanExpressionsController.java (96%) rename {spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model => spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml}/Course.java (95%) rename {spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller => spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml}/CourseRegistrationController.java (83%) rename spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/{controller => requestparameters}/ParticipantController.java (94%) rename {spring-thymeleaf/src/main/webapp/WEB-INF/views => spring-thymeleaf-2/src/main/resources/templates}/booleans.html (100%) rename {spring-thymeleaf => spring-thymeleaf-2}/src/main/resources/templates/continents.html (100%) rename {spring-thymeleaf/src/main/webapp/WEB-INF/views => spring-thymeleaf-2/src/main/resources/templates}/courseRegistration.html (100%) delete mode 100644 spring-thymeleaf/.gitignore delete mode 100644 spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/WorkingWithArraysInThymeleafApplication.java rename spring-thymeleaf/src/test/java/{org/baeldung => com/baeldung/thymeleaf}/SpringContextIntegrationTest.java (95%) rename spring-thymeleaf/src/test/java/{org/baeldung => com/baeldung/thymeleaf}/SpringContextTest.java (95%) rename spring-thymeleaf/src/test/java/{org/baeldung => com/baeldung/thymeleaf}/security/csrf/CsrfEnabledIntegrationTest.java (98%) diff --git a/spring-thymeleaf-2/README.md b/spring-thymeleaf-2/README.md index e7f0c60add..9f727f30ca 100644 --- a/spring-thymeleaf-2/README.md +++ b/spring-thymeleaf-2/README.md @@ -1,6 +1,16 @@ +## Spring Thymeleaf + +This module contains articles about Spring with Thymeleaf + ## Relevant Articles: - [Working with Enums in Thymeleaf](https://www.baeldung.com/thymeleaf-enums) - [Changing the Thymeleaf Template Directory in Spring Boot](https://www.baeldung.com/spring-thymeleaf-template-directory) - [Spring Request Parameters with Thymeleaf](https://www.baeldung.com/spring-thymeleaf-request-parameters) - [Thymeleaf lists Utility Object](https://www.baeldung.com/thymeleaf-lists-utility) +- [Working with Arrays in Thymeleaf](https://www.baeldung.com/thymeleaf-arrays) +- [Spring Path Variables with Thymeleaf](https://www.baeldung.com/spring-thymeleaf-path-variables) +- [Working with Boolean in Thymeleaf](https://www.baeldung.com/thymeleaf-boolean) +- [Working With Custom HTML Attributes in Thymeleaf](https://www.baeldung.com/thymeleaf-custom-html-attributes) +- [How to Create an Executable JAR with Maven](https://www.baeldung.com/executable-jar-with-maven) +- [[<-- prev]](/spring-thymeleaf) \ No newline at end of file diff --git a/spring-thymeleaf-2/pom.xml b/spring-thymeleaf-2/pom.xml index d31e5fa7f6..d53bb8ab1a 100644 --- a/spring-thymeleaf-2/pom.xml +++ b/spring-thymeleaf-2/pom.xml @@ -35,6 +35,27 @@ org.apache.maven.plugins maven-war-plugin + + + org.apache.tomcat.maven + tomcat7-maven-plugin + ${tomcat7-maven-plugin.version} + + + tomcat-run + + exec-war-only + + package + + / + false + webapp.jar + utf-8 + + + + spring-thymeleaf-2 @@ -42,5 +63,6 @@ 1.8 1.8 + 2.2 diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ThymeleafArrayController.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java similarity index 92% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ThymeleafArrayController.java rename to spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java index 8276cc4376..d137cbdf94 100644 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ThymeleafArrayController.java +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java @@ -1,4 +1,4 @@ -package com.baeldung.thymeleaf.controller; +package com.baeldung.thymeleaf.arrays; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BooleanExpressionsController.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java similarity index 96% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BooleanExpressionsController.java rename to spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java index 3a640e1499..e43e08334a 100644 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BooleanExpressionsController.java +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java @@ -1,4 +1,4 @@ -package com.baeldung.thymeleaf.controller; +package com.baeldung.thymeleaf.booleanexpressions; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Course.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java similarity index 95% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Course.java rename to spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java index df2e9cd097..9bf8e5e52c 100644 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Course.java +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java @@ -1,4 +1,4 @@ -package com.baeldung.thymeleaf.model; +package com.baeldung.thymeleaf.customhtml; import java.util.Date; diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/CourseRegistrationController.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java similarity index 83% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/CourseRegistrationController.java rename to spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java index 2d2b5906e1..06e81ecba8 100644 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/CourseRegistrationController.java +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java @@ -1,4 +1,4 @@ -package com.baeldung.thymeleaf.controller; +package com.baeldung.thymeleaf.customhtml; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -6,8 +6,6 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import com.baeldung.thymeleaf.model.Course; - /** * Handles requests for the student model. * @@ -18,13 +16,13 @@ public class CourseRegistrationController { @RequestMapping(value = "/registerCourse", method = RequestMethod.POST) public String register(@ModelAttribute Course course, Model model) { model.addAttribute("successMessage", "You have successfully registered for course: " + course.getName() + "."); - return "courseRegistration.html"; + return "templates/courseRegistration.html"; } @RequestMapping(value = "/registerCourse", method = RequestMethod.GET) public String register(Model model) { model.addAttribute("course", new Course()); - return "courseRegistration.html"; + return "templates/courseRegistration.html"; } } diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/controller/ParticipantController.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java similarity index 94% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/controller/ParticipantController.java rename to spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java index 9a354e709c..faa4ae0cf9 100644 --- a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/controller/ParticipantController.java +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java @@ -1,4 +1,4 @@ -package com.baeldung.thymeleaf.controller; +package com.baeldung.thymeleaf.requestparameters; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/booleans.html b/spring-thymeleaf-2/src/main/resources/templates/booleans.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/booleans.html rename to spring-thymeleaf-2/src/main/resources/templates/booleans.html diff --git a/spring-thymeleaf/src/main/resources/templates/continents.html b/spring-thymeleaf-2/src/main/resources/templates/continents.html similarity index 100% rename from spring-thymeleaf/src/main/resources/templates/continents.html rename to spring-thymeleaf-2/src/main/resources/templates/continents.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/courseRegistration.html b/spring-thymeleaf-2/src/main/resources/templates/courseRegistration.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/courseRegistration.html rename to spring-thymeleaf-2/src/main/resources/templates/courseRegistration.html diff --git a/spring-thymeleaf/.gitignore b/spring-thymeleaf/.gitignore deleted file mode 100644 index b83d22266a..0000000000 --- a/spring-thymeleaf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/spring-thymeleaf/README.md b/spring-thymeleaf/README.md index 329ef8580c..a5c6791609 100644 --- a/spring-thymeleaf/README.md +++ b/spring-thymeleaf/README.md @@ -9,16 +9,11 @@ This module contains articles about Spring with Thymeleaf - [Spring and Thymeleaf 3: Expressions](https://www.baeldung.com/spring-thymeleaf-3-expressions) - [Spring MVC + Thymeleaf 3.0: New Features](https://www.baeldung.com/spring-thymeleaf-3) - [How to Work with Dates in Thymeleaf](https://www.baeldung.com/dates-in-thymeleaf) -- [How to Create an Executable JAR with Maven](https://www.baeldung.com/executable-jar-with-maven) -- [Working with Boolean in Thymeleaf](https://www.baeldung.com/thymeleaf-boolean) - [Working with Fragments in Thymeleaf](https://www.baeldung.com/spring-thymeleaf-fragments) - [Conditionals in Thymeleaf](https://www.baeldung.com/spring-thymeleaf-conditionals) - [Iteration in Thymeleaf](https://www.baeldung.com/thymeleaf-iteration) -- [Working With Arrays in Thymeleaf](https://www.baeldung.com/thymeleaf-arrays) - [Spring with Thymeleaf Pagination for a List](https://www.baeldung.com/spring-thymeleaf-pagination) - [Working with Select and Option in Thymeleaf](https://www.baeldung.com/thymeleaf-select-option) -- [Working With Custom HTML Attributes in Thymeleaf](https://www.baeldung.com/thymeleaf-custom-html-attributes) -- [Spring Request Parameters with Thymeleaf](https://www.baeldung.com/spring-thymeleaf-request-parameters) - [[next -->]](/spring-thymeleaf-2) ### Build the Project @@ -35,7 +30,6 @@ Access the pages using the URLs: - http://localhost:8082/spring-thymeleaf/ - http://localhost:8082/spring-thymeleaf/addStudent/ - http://localhost:8082/spring-thymeleaf/listStudents/ - - http://localhost:8082/spring-thymeleaf/booleans/ The first URL is the home page of the application. The home page has links to the second and third pages. diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index cdc2ed25ae..d260a78d76 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -141,26 +141,6 @@ - - org.apache.tomcat.maven - tomcat7-maven-plugin - ${tomcat7-maven-plugin.version} - - - tomcat-run - - exec-war-only - - package - - / - false - webapp.jar - utf-8 - - - - @@ -174,7 +154,6 @@ 1.6.1 - 2.2 diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/WorkingWithArraysInThymeleafApplication.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/WorkingWithArraysInThymeleafApplication.java deleted file mode 100644 index bce0660fda..0000000000 --- a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/WorkingWithArraysInThymeleafApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -// package com.baeldung.thymeleaf; - -// import org.springframework.boot.SpringApplication; -// import org.springframework.boot.autoconfigure.SpringBootApplication; - -// @SpringBootApplication -// public class WorkingWithArraysInThymeleafApplication { - -// public static void main(String[] args) { -// SpringApplication.run(WorkingWithArraysInThymeleafApplication.class, args); -// } -// } diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html index 25ff6a19bb..b458f7270c 100644 --- a/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html +++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html @@ -24,9 +24,6 @@ - - - diff --git a/spring-thymeleaf/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextIntegrationTest.java similarity index 95% rename from spring-thymeleaf/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextIntegrationTest.java index c7a0b4fc60..9a066b3101 100644 --- a/spring-thymeleaf/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextIntegrationTest.java @@ -1,15 +1,14 @@ -package org.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; +package com.baeldung.thymeleaf; import com.baeldung.thymeleaf.config.InitSecurity; import com.baeldung.thymeleaf.config.WebApp; import com.baeldung.thymeleaf.config.WebMVCConfig; import com.baeldung.thymeleaf.config.WebMVCSecurity; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration diff --git a/spring-thymeleaf/src/test/java/org/baeldung/SpringContextTest.java b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java similarity index 95% rename from spring-thymeleaf/src/test/java/org/baeldung/SpringContextTest.java rename to spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java index 1ff1c52c68..cbd3f85b48 100644 --- a/spring-thymeleaf/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java @@ -1,15 +1,14 @@ -package org.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; +package com.baeldung.thymeleaf; import com.baeldung.thymeleaf.config.InitSecurity; import com.baeldung.thymeleaf.config.WebApp; import com.baeldung.thymeleaf.config.WebMVCConfig; import com.baeldung.thymeleaf.config.WebMVCSecurity; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration diff --git a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java similarity index 98% rename from spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java rename to spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java index 4f6480e3b2..a7c9fb4ae4 100644 --- a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java +++ b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java @@ -1,12 +1,9 @@ -package org.baeldung.security.csrf; - -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import javax.servlet.Filter; +package com.baeldung.thymeleaf.security.csrf; +import com.baeldung.thymeleaf.config.InitSecurity; +import com.baeldung.thymeleaf.config.WebApp; +import com.baeldung.thymeleaf.config.WebMVCConfig; +import com.baeldung.thymeleaf.config.WebMVCSecurity; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,10 +18,12 @@ import org.springframework.test.web.servlet.request.RequestPostProcessor; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.thymeleaf.config.InitSecurity; -import com.baeldung.thymeleaf.config.WebApp; -import com.baeldung.thymeleaf.config.WebMVCConfig; -import com.baeldung.thymeleaf.config.WebMVCSecurity; +import javax.servlet.Filter; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration