mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 06:45:49 +00:00
.
This commit is contained in:
parent
683ae9e0b9
commit
8b3d8f8e8f
3 changed files with 39 additions and 3 deletions
|
@ -0,0 +1,4 @@
|
|||
package org.springframework.samples.petclinic.product;
|
||||
|
||||
public class Product {
|
||||
}
|
|
@ -3,10 +3,19 @@ package org.springframework.samples.petclinic.product;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.ui.Model;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@RestController
|
||||
public class ProductController {
|
||||
@GetMapping("/products")
|
||||
public String showProductList(){
|
||||
return "Hello!";
|
||||
public String showProductList(Model model){
|
||||
List<Product> prods = new ArrayList<Product>();
|
||||
model.addAttribute("product",prods);
|
||||
//prods.add(new Product("p1");
|
||||
//prods.add(new Product("P2"));
|
||||
return "products/productsList";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
23
src/main/resources/templates/products/products.List.html
Normal file
23
src/main/resources/templates/products/products.List.html
Normal 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>
|
Loading…
Reference in a new issue