Commit 62450b01 by Patryk Czarnik

SpringData - przygotowania...

parent 90e1f863
package alx.data;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/emps9")
public class Controller9 {
@GetMapping
public String readAll() {
return "employees.html";
}
}
......@@ -34,3 +34,17 @@ form {
color: red;
font-weight: bold;
}
table {
border-collapse: collapse;
background-color: white;
}
th, td {
border: 1px solid #444444;
padding: 4px;
}
th {
background-color: #CCCCCC;
}
\ No newline at end of file
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Employees</title>
<link rel="stylesheet" type="text/css" th:href="@{/styl.css}">
</head>
<body>
<table>
<tr>
<th>Imię</th><th>Nazwisko</th><th>Stanowisko</th><th>Pensja</th><th>Departament</th><th>Miasto</th>
</tr>
<tr th:each="emp : ${emps}">
<td th:text="${emp.firstName}">firstName</td>
<td th:text="${emp.lastName}">lastName</td>
<td th:text="${emp.job.jobTitle}">jobTitle</td>
<td th:text="${emp.salary}">salary</td>
<td th:text="${emp.department.departmentName}" th:if="${emp.department != null}">departmentName</td>
<td th:text="${emp.department.location.city}" th:if="${emp.department != null}">city</td>
</tr>
</table>
<p><a th:href="@{/}">wróć do spisu treści</a></p>
</body>
</html>
......@@ -45,10 +45,13 @@
<h2>Wstrzykiwanie na 3 sposoby</h2>
<ul>
<li><a href="/inject1">Wstrzykiwanie 1</a> - pole</li>
<li><a href="/inject2">Wstrzykiwanie 2</a> - setter</li>
<li><a href="/inject3">Wstrzykiwanie 3</a> - konstruktor</li>
<li><a th:href="@{/inject1}">Wstrzykiwanie 1</a> - pole</li>
<li><a th:href="@{/inject2}">Wstrzykiwanie 2</a> - setter</li>
<li><a th:href="@{/inject3}">Wstrzykiwanie 3</a> - konstruktor</li>
</ul>
<h2>Spring Data</h2>
<p><a th:href="@{/emps9}">TERAZ</a></p>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment