Skip to content

Commit

Permalink
Thymeleaf Templates
Browse files Browse the repository at this point in the history
  • Loading branch information
DraconYale committed Apr 14, 2024
1 parent 324b0d6 commit 25ec88f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public String getBooks(Model model){

model.addAttribute("books", bookRepository.findAll());

return "books";
return "books/list";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public String toString() {
"id=" + id +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", books=" + books +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public String toString() {
"id=" + id +
", title='" + title + '\'' +
", isbn='" + isbn + '\'' +
", authors=" + authors +
'}';
}

Expand Down
24 changes: 24 additions & 0 deletions src/main/resources/templates/books/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>Spring Framework Guru</title>
</head>
<body>
<h1>Book List</h1>

<table>
<tr>
<th>ID</th>
<th>Title</th>
<th>Publisher</th>
</tr>
<tr th:each="book : ${books}">
<td th:text="${book.id}">123</td>
<td th:text="${book.title}"> Spring in Action</td>
<td th:text="${book.publisher.name}">Wrox</td>
</tr>
</table>

</body>
</html>

0 comments on commit 25ec88f

Please sign in to comment.