This commit is contained in:
ipagnoncelli 2019-08-09 17:10:14 -03:00
parent 683ae9e0b9
commit 8b3d8f8e8f
3 changed files with 39 additions and 3 deletions

View file

@ -0,0 +1,4 @@
package org.springframework.samples.petclinic.product;
public class Product {
}

View file

@ -3,10 +3,19 @@ package org.springframework.samples.petclinic.product;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.ui.Model;
import java.util.ArrayList;
import java.util.List;
@RestController @RestController
public class ProductController { public class ProductController {
@GetMapping("/products") @GetMapping("/products")
public String showProductList(){ public String showProductList(Model model){
return "Hello!"; List<Product> prods = new ArrayList<Product>();
model.addAttribute("product",prods);
//prods.add(new Product("p1");
//prods.add(new Product("P2"));
return "products/productsList";
} }
} }

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Product List</title>
</head>
<body>
<h2>Product List</h2>
<table id = "vets" class = "table table-striped"></table>
<thead>
<tr>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr th: each="product : ${products}">
<td th:text = "${project.description}"
</tr>
</tbody>
</body>
</html>