Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <tbody>
- <tr data-th-each="product : ${products}">
- <!--<td><input hidden="hidden" name="id" th:value="${product.id}" /></td>-->
- <td th:text="${product.name}"></td>
- <td th:text="${product.price}"></td>
- <td th:each="category : ${product.categories}"></td>
- <td th:text="${category.name}"></td>
- <td th:text="${product.description}"></td>
- <td th:text="${product.shippingWeight}"></td>
- <td th:text="${product.quantity}"></td>
- <td>delete</td>
- </tr>
- </tbody>
- @NoArgsConstructor
- @AllArgsConstructor
- @Getter
- @Setter
- @Entity
- @Table(name = "products")
- public class Product {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name = "product_id")
- private Long id;
- private String name;
- private BigDecimal price;
- @ManyToMany(cascade = CascadeType.ALL,mappedBy = "products")
- private List<Category> categories=new ArrayList<>();
- private double shippingWeight;
- private boolean isAvailable;
- private String description;
- private int quantity;
- @Transient
- private MultipartFile image;
- @AllArgsConstructor
- @NoArgsConstructor
- @Getter
- @Setter
- @Entity
- @Table(name = "categories")
- public class Category {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(name = "category_id")
- private Long id;
- private String name;
- private String description;
- @ManyToMany(cascade = CascadeType.ALL)
- @JoinTable(name = "join_category_product", joinColumns = {@JoinColumn(name = "category_id", referencedColumnName = "category_id")},
- inverseJoinColumns = {@JoinColumn(name = "product_id", referencedColumnName = "product_id")})
- private List<Product> products=new ArrayList<>();
- @Transient
- private MultipartFile image;
- @GetMapping("/productList")
- public String productList(Model model) {
- List<Product> product = productService.getProducts();
- model.addAttribute("products",product);
- return "productList";
Add Comment
Please, Sign In to add comment