diff options
| author | Kamal Wickramanayake <kamal@inbox.lk> | 2026-06-20 18:25:56 +0530 |
|---|---|---|
| committer | Kamal Wickramanayake <kamal@inbox.lk> | 2026-06-20 18:25:56 +0530 |
| commit | 41b068b6d48f9d82babd1cfce3520ad0b28be861 (patch) | |
| tree | 0a9db394d2f14b7f14c3b1d167f56d4dfecd4563 /spring-boot/10-role-based-security/src/main/resources/templates | |
| parent | 8c66a82e0caa71c3bb1c1dc40d91272f51c1c0f5 (diff) | |
Added Spring Boot role based security sample application
Diffstat (limited to 'spring-boot/10-role-based-security/src/main/resources/templates')
4 files changed, 98 insertions, 0 deletions
diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/contact/form.html b/spring-boot/10-role-based-security/src/main/resources/templates/contact/form.html new file mode 100644 index 0000000..7debe1f --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/contact/form.html @@ -0,0 +1,30 @@ +<!DOCTYPE HTML> +<html xmlns:th="http://www.thymeleaf.org" th:replace="~{layout/main :: layout(title='Contact Us', content=~{::main})}"> + +<body> + <main> + <form th:action="@{/contact}" th:object="${contactForm}" method="post"> + <div class="form-field-container"> + <label>Name</label> + <input type="text" th:field="*{name}" placeholder="Your name" /> + <div class="validation-error" th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></div> + </div> + + <div class="form-field-container"> + <label>Email</label> + <input type="email" th:field="*{email}" placeholder="Your email" /> + <div class="validation-error" th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></div> + </div> + + <div class="form-field-container"> + <label>Message</label> + <textarea th:field="*{message}" placeholder="Your message"></textarea> + <div class="validation-error" th:if="${#fields.hasErrors('message')}" th:errors="*{message}"></div> + </div> + + <button type="submit">Send</button> + </form> + </main> +</body> + +</html>
\ No newline at end of file diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/contact/result.html b/spring-boot/10-role-based-security/src/main/resources/templates/contact/result.html new file mode 100644 index 0000000..d1bda9a --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/contact/result.html @@ -0,0 +1,14 @@ +<!DOCTYPE HTML> +<html xmlns:th="http://www.thymeleaf.org" th:replace="~{layout/main :: layout(title='Contact Us', content=~{::main})}"> + +<body> + <main> + <p>We received your message.</p> + + <p th:text="'Thank you ' + ${contactForm.name} + '.'" /> + + <a th:href="@{/contact}">Try again</a> + </main> +</body> + +</html>
\ No newline at end of file diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/index.html b/spring-boot/10-role-based-security/src/main/resources/templates/index.html new file mode 100644 index 0000000..dce7a4e --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/index.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML> +<html xmlns:th="http://www.thymeleaf.org" + xmlns:sec="http://thymeleaf.org/extras/spring-security" + th:replace="~{layout/main :: layout(title='Welcome', content=~{::main})}"> + +<body> + <main> + <p>Hello, <span sec:authentication="name">Username Placeholder</span>!</p> + + <p>Hello, [[${#authentication.name}]]!</p> + + <p>This is the home page content.</p> + + <p>Use the navigation links to explore other pages.</p> + </main> +</body> + +</html>
\ No newline at end of file diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/layout/main.html b/spring-boot/10-role-based-security/src/main/resources/templates/layout/main.html new file mode 100644 index 0000000..df96fc5 --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/layout/main.html @@ -0,0 +1,36 @@ +<!DOCTYPE HTML> +<html xmlns:th="http://www.thymeleaf.org" + xmlns:sec="http://thymeleaf.org/extras/spring-security" + th:fragment="layout(title, content)"> + +<head> + <title th:text="|${title} - ABC App|">Base title not shown</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <link rel="stylesheet" th:href="@{/css/main.css}" /> +</head> + +<body> + <header> + <h1>ABC App</h1> + </header> + + <nav class="main-nav"> + <ul> + <li><a th:href="@{/}">Home</a></li> + <li><a th:href="@{/contact}">Contact Us</a></li> + <li sec:authorize="hasRole('ADMIN')"><a th:href="@{/admin}">Admin</a></li> + <li sec:authorize="isAuthenticated()"><a th:href="@{/profile/{name}(name=${#authentication.name})}">Profile</a></li> + <li sec:authorize="isAuthenticated()"><a th:href="@{/logout}">Logout</a></li> + </ul> + </nav> + + <h3 th:text="|${title}|">Page content area title</h3> + + <th:block th:replace="${content}" /> + + <footer> + Copyright © 2026 Example Company. All rights reserved. + </footer> +</body> + +</html>
\ No newline at end of file |
