crud implementation #2

Open
romanov73 wants to merge 7 commits from crud into master
2 changed files with 160 additions and 54 deletions
Showing only changes of commit 2ec0ca5716 - Show all commits

View File

@ -2,29 +2,77 @@
<html xmlns:th="http://www.thymeleaf.org"> <html xmlns:th="http://www.thymeleaf.org">
<head> <head>
<title>Простая обработка формы на Spring MVC</title> <title>Простая обработка формы на Spring MVC</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
</head> </head>
<body> <body>
<h1>Форма</h1> <!-- компонент меню-->
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Название web-приложения</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/">Главная страница</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/list">Список отправленных сообщений</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
Выпадающее меню
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Пункт 1</a></li>
<li><a class="dropdown-item" href="#">Пункт 3</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Пункт 3</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled">Недоступно</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8 col-sm-12">
<h2>Форма</h2>
<form action="#" th:action="@{/sendEmail}" th:object="${emailForm}" method="post"> <form action="#" th:action="@{/sendEmail}" th:object="${emailForm}" method="post">
<p style="color:red" th:text="${error}"></p> <p style="color:red" th:text="${error}"></p>
<table> <div class="form-group">
<tr> <label for="theme">Тема</label>
<td>Тема:</td> <input type="text" class="form-control" id="theme" placeholder="Введите тему" th:field="*{subject}">
<td><input type="text" th:field="*{subject}"/></td> </div>
</tr> <div class="form-group">
<tr> <label for="to">Кому</label>
<td>Кому:</td> <input class="form-control" type="email" id="to" th:field="*{to}" placeholder="Кому"/>
<td><input type="text" th:field="*{to}"/></td> </div>
</tr> <div class="form-group">
<tr> <label for="message">Сообщение</label>
<td>Сообщение:</td> <textarea class="form-control" id="message" th:field="*{message}" placeholder="Сообщение"/>
<td><textarea th:field="*{message}"/></td> </div>
</tr> <input class="form-group" type="submit" value="Отправить"/>
<tr>
<td colspan="2"><input type="submit" value="Отправить"/></td>
</tr>
</table>
</form> </form>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8"
crossorigin="anonymous"></script>
</body> </body>
</html> </html>

View File

@ -3,21 +3,73 @@
<head> <head>
<title>Список записей в БД</title> <title>Список записей в БД</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" <meta charset="utf-8">
integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"
<!-- Optional theme --> integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
crossorigin="anonymous"></script>
</head> </head>
<body> <body>
<h1>Список записей в БД:</h1> <!-- компонент меню-->
<table class="table table-striped"> <nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Название web-приложения</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/">Главная страница</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/list">Список отправленных сообщений</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
Выпадающее меню
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Пункт 1</a></li>
<li><a class="dropdown-item" href="#">Пункт 3</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Пункт 3</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled">Недоступно</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8 col-sm-12">
<h2>Список записей в БД:</h2>
<div class="row">
<div class="col-md-4" style="font-weight: bold">
Кому
</div>
<div class="col-md-4" style="font-weight: bold">
Тема
</div>
<div class="col-md-4" style="font-weight: bold">
Сообщение
</div>
</div>
<div class="row" th:each="email: ${emails}">
<div class="col-md-4" th:text="${email.to}"/>
<div class="col-md-4" th:text="${email.subject}"/>
<div class="col-md-4" th:text="${email.message}"/>
</div>
<!--<table class="table table-striped">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th scope="col">Кому</th> <th scope="col">Кому</th>
@ -35,8 +87,14 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>-->
<a href="/">Отправить другое сообщение</a> <a href="/">Отправить другое сообщение</a>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8"
crossorigin="anonymous"></script>
</body> </body>
</html> </html>