diff --git a/spring-thymeleaf/README.md b/spring-thymeleaf/README.md
index 2c37e73ada..4d152aee8a 100644
--- a/spring-thymeleaf/README.md
+++ b/spring-thymeleaf/README.md
@@ -10,6 +10,7 @@
- [Spring MVC + Thymeleaf 3.0: New Features](http://www.baeldung.com/spring-thymeleaf-3)
- [How to Work with Dates in Thymeleaef](http://www.baeldung.com/dates-in-thymeleaf)
- [How to Create an Executable JAR with Maven](http://www.baeldung.com/executable-jar-with-maven)
+- [Working with Booleans in Thymeleaf](http://www.baeldung.com/working-with-booleans-in-thymeleaf)
### Build the Project
@@ -22,11 +23,12 @@ mvn cargo:run
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/
+ - 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 other two pages.
+The first URL is the home page of the application. The home page has links to the second and third pages.
### Security
The user/password required is: user1/user1Pass
diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BooleanExpressionsController.java b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BooleanExpressionsController.java
new file mode 100644
index 0000000000..3a640e1499
--- /dev/null
+++ b/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BooleanExpressionsController.java
@@ -0,0 +1,45 @@
+package com.baeldung.thymeleaf.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * Controller to test boolean expressions
+ *
+ */
+@Controller
+public class BooleanExpressionsController {
+
+ @RequestMapping(value = "/booleans", method = RequestMethod.GET)
+ public String getDates(Model model) {
+ // "truthy" values
+ model.addAttribute("trueValue", true);
+ model.addAttribute("one", 1);
+ model.addAttribute("nonZeroCharacter", 'a');
+ model.addAttribute("emptyString", "");
+ model.addAttribute("foo", "foo");
+ model.addAttribute("object", new Object());
+ model.addAttribute("arrayOfZeros", new Integer[] { 0, 0 });
+ model.addAttribute("arrayOfZeroAndOne", new Integer[] { 0, 1 });
+ model.addAttribute("arrayOfOnes", new Integer[] { 1, 1 });
+
+ // "falsy" values
+ model.addAttribute("nullValue", null);
+ model.addAttribute("falseValue", false);
+ model.addAttribute("zero", 0);
+ model.addAttribute("zeroCharacter", '\0');
+ model.addAttribute("falseString", "false");
+ model.addAttribute("no", "no");
+ model.addAttribute("off", "off");
+
+ model.addAttribute("isRaining", true);
+ model.addAttribute("isSunny", true);
+ model.addAttribute("isCold", false);
+ model.addAttribute("isWarm", true);
+
+ return "booleans.html";
+ }
+
+}
diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/booleans.html b/spring-thymeleaf/src/main/webapp/WEB-INF/views/booleans.html
new file mode 100644
index 0000000000..63d894421b
--- /dev/null
+++ b/spring-thymeleaf/src/main/webapp/WEB-INF/views/booleans.html
@@ -0,0 +1,179 @@
+
+
+
+
+Expression utility objects
+
+
+
+ 'Truthy' and 'falsy' expressions
+
+ - 'true' is evaluated to
+ - '1' is evaluated to
+ - non zero character is evaluated to
+ - empty string is evaluated to
+ - the string "foo" is evaluated to
+ - an object is evaluated to
+ - the array [0, 0] is evaluated to
+ - the array [0, 1] is evaluated to
+ - the array [1, 1] is evaluated to
+
+ - null value is evaluated to
+ - 'false' is evaluated to
+ - '0' is evaluated to
+ - zero character is evaluated to
+ - the string "false" is evaluated to
+ - the string "no" is evaluated to
+ - the string "off" is evaluated to
+
+
+ Using booleans as rendering conditions
+
+
+ |
+ th:if |
+ th:unless |
+
+
+ true |
+ will be rendered |
+ won't be rendered |
+
+
+ false |
+ won't be rendered |
+ will be rendered |
+
+
+
+ Boolean and conditional operators
+
+
+ A |
+ B |
+ ${A or B} |
+ ${A} or ${B} |
+ ${A and B} |
+ ${A} and ${B} |
+ ${!A} |
+ !${A} |
+ ${not A} |
+ not ${A} |
+
+
+ true |
+ true |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+ true |
+ false |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+ false |
+ true |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+ false |
+ false |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+ - the result of "true ? 'then'" is
+ - the result of "false ? 'then'" is
+ - the result of "true ? 'then' : 'else'" is
+ - the result of "false ? 'then' : 'else'" is
+ - the result of "'foo' ?: 'bar'" is
+ - the result of "null ?: 'bar'" is
+ - the result of "0 ?: 'bar'" is
+ - the result of "1 ?: 'bar'" is
+
+
+
+ - The weather is bad
+ - The weather is bad
+ - The weather is good
+ - The weather is good
+ - It's warm
+ - It's warm
+ - It's warm
+ - It's warm
+ - It's
+
+
+
+ #bools utility object
+
+
+ Array |
+ #bools.arrayIsTrue() |
+ #bools.arrayIsFalse() |
+ #bools.arrayAnd() |
+ #bools.arrayOr() |
+
+
+ [0, 0] |
+ |
+ |
+ |
+ |
+
+
+ [0, 1] |
+ |
+ |
+ |
+ |
+
+
+ [1, 1] |
+ |
+ |
+ |
+ |
+
+
+
+
\ No newline at end of file