diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index 61d41e5f20..2c3740f1e8 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -98,6 +98,19 @@ ${springframework-security.version} test + + @@ -105,6 +118,7 @@ spring-data-commons ${springFramework-data.version} + @@ -117,6 +131,7 @@ false + org.codehaus.cargo cargo-maven2-plugin @@ -136,6 +151,7 @@ + org.apache.tomcat.maven tomcat7-maven-plugin diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/WorkingWithArraysInThymeleafApplication.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/WorkingWithArraysInThymeleafApplication.java new file mode 100644 index 0000000000..bce0660fda --- /dev/null +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/WorkingWithArraysInThymeleafApplication.java @@ -0,0 +1,12 @@ +// 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/java/com/baeldung/thymeleaf/controller/ThymeleafArrayController.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ThymeleafArrayController.java new file mode 100644 index 0000000000..8276cc4376 --- /dev/null +++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ThymeleafArrayController.java @@ -0,0 +1,17 @@ +package com.baeldung.thymeleaf.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class ThymeleafArrayController { + @GetMapping("/arrays") + public String arrayController(Model model) { + String[] continents = {"Africa", "Antarctica", "Asia", "Australia", "Europe", "North America", "Sourth America"}; + + model.addAttribute("continents", continents); + + return "continents"; + } +} diff --git a/spring-thymeleaf/src/main/resources/templates/continents.html b/spring-thymeleaf/src/main/resources/templates/continents.html new file mode 100644 index 0000000000..0e7ffa3f58 --- /dev/null +++ b/spring-thymeleaf/src/main/resources/templates/continents.html @@ -0,0 +1,49 @@ + + + + Arrays in Thymeleaf + + + + + +

THE CONTINENTS

+

+ We have a total of + continents in this world. Following is a list showing their order + based on the number of population in each of them. +

+ +
    +
  1. +
  2. +
  3. +
  4. +
  5. +
  6. +
  7. +
+ + + +

+ +

+ The greatest + continents. +

+ +

+ Europe is a continent: . +

+ +

+ Array of continents is empty . +

+ + +