diff --git a/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/attribute/CheckedAttributeController.java b/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/attribute/CheckedAttributeController.java new file mode 100644 index 0000000000..165e98ac3a --- /dev/null +++ b/spring-web-modules/spring-thymeleaf-5/src/main/java/com/baeldung/thymeleaf/attribute/CheckedAttributeController.java @@ -0,0 +1,29 @@ +package com.baeldung.thymeleaf.attribute; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class CheckedAttributeController { + + @GetMapping("/checked") + public String displayCheckboxForm(Model model) { + Engine engine = new Engine(true); + model.addAttribute("engine", engine); + model.addAttribute("flag", true); + return "attribute/index"; + } + + private static class Engine { + private Boolean active; + + public Engine(Boolean active) { + this.active = active; + } + + public Boolean getActive() { + return active; + } + } +} diff --git a/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/attribute/index.html b/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/attribute/index.html new file mode 100644 index 0000000000..a7c5b90296 --- /dev/null +++ b/spring-web-modules/spring-thymeleaf-5/src/main/resources/templates/attribute/index.html @@ -0,0 +1,27 @@ + + +
+ +