summaryrefslogtreecommitdiff
path: root/spring-boot/06-form-handling-with-thymeleaf/src/main/resources
diff options
context:
space:
mode:
Diffstat (limited to 'spring-boot/06-form-handling-with-thymeleaf/src/main/resources')
-rw-r--r--spring-boot/06-form-handling-with-thymeleaf/src/main/resources/application.properties0
-rw-r--r--spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/form.html36
-rw-r--r--spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/result.html16
-rw-r--r--spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/index.html18
4 files changed, 70 insertions, 0 deletions
diff --git a/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/application.properties b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/application.properties
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/application.properties
diff --git a/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/form.html b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/form.html
new file mode 100644
index 0000000..0229e0d
--- /dev/null
+++ b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/form.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org">
+
+<head>
+ <title>Contact Us</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+</head>
+
+<body>
+ <h1>Contact Us</h1>
+
+ <form th:action="@{/contact}" th:object="${contactForm}" method="post">
+ <div>
+ <label>Name</label>
+ <input type="text" th:field="*{name}" placeholder="Your name" />
+ <div th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></div>
+ </div>
+
+ <div>
+ <label>Email</label>
+ <input type="email" th:field="*{email}" placeholder="Your email" />
+ <div th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></div>
+ </div>
+
+ <div>
+ <label>Message</label>
+ <textarea th:field="*{message}" placeholder="Your message"></textarea>
+ <div th:if="${#fields.hasErrors('message')}" th:errors="*{message}"></div>
+ </div>
+
+ <button type="submit">Send</button>
+ </form>
+
+</body>
+
+</html> \ No newline at end of file
diff --git a/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/result.html b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/result.html
new file mode 100644
index 0000000..1bb4b45
--- /dev/null
+++ b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/contact/result.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+ <title>Contact Us</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+</head>
+<body>
+ <h1>Contact Us</h1>
+
+ <p>We received your message.</p>
+
+ <p th:text="'Thank you ' + ${contactForm.name} + '.'" />
+
+ <a href="/contact">Try again</a>
+</body>
+</html> \ No newline at end of file
diff --git a/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/index.html b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/index.html
new file mode 100644
index 0000000..48e251d
--- /dev/null
+++ b/spring-boot/06-form-handling-with-thymeleaf/src/main/resources/templates/index.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org">
+
+<head>
+ <title>Form handling example with Thymeleaf</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+</head>
+
+<body>
+
+<h1>Form handling example with Thymeleaf</h1>
+
+<a href="/contact">Contact Us</a>
+
+</body>
+
+</html>
+