mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 14:55:51 +00:00
View finish!
This commit is contained in:
parent
75fe7380cb
commit
805c176081
4 changed files with 37 additions and 6 deletions
|
@ -1,4 +1,14 @@
|
|||
package org.springframework.samples.petclinic.products;
|
||||
|
||||
public class Product {
|
||||
private String description;
|
||||
private String name;
|
||||
|
||||
public Product(String description, String name){
|
||||
this.description = description;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public String getName() { return name; }
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@ public class ProductsController {
|
|||
@GetMapping("/products")
|
||||
public String showProductList(Model model){
|
||||
List<Product> prods = new ArrayList<Product>();
|
||||
model.addAttribute("Products", prods);
|
||||
model.addAttribute("products", prods);
|
||||
prods.add(new Product("Produto 1", "p1"));
|
||||
prods.add(new Product("Produto 2", "p2"));
|
||||
|
||||
return "products/productsList";
|
||||
}
|
||||
|
|
|
@ -59,9 +59,9 @@
|
|||
<span>Veterinarians</span>
|
||||
</li>
|
||||
|
||||
<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign','Error')">
|
||||
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
|
||||
<span>Error</span>
|
||||
<li th:replace="::menuItem ('/products','products','products list','ph-list','products')">
|
||||
<span class="glyphicon glyphicon-ph-list" aria-hidden="true"></span>
|
||||
<span>ProductList</span>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
|
@ -1,10 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<html xmlns:th="https://www.thymeleaf.org"
|
||||
th:replace="~{fragments/layout :: layout (~{::body},'products')}">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h3>asdasdasdad</h3>
|
||||
|
||||
<h2>Product List</h2>
|
||||
|
||||
<table id="products" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="product : ${products}">
|
||||
<td th:text="${product.name}"></td>
|
||||
<td th:text="${product.description}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue