Commit 9fb49957 by Patryk Czarnik

product.jsp

parent 363e9371
...@@ -31,8 +31,8 @@ public class AlternatywneProdukty2 { ...@@ -31,8 +31,8 @@ public class AlternatywneProdukty2 {
@GetMapping("/products/{id}") @GetMapping("/products/{id}")
public String oneProduct(Model model, @PathVariable int id) { public String oneProduct(Model model, @PathVariable int id) {
Product product = em.find(Product.class, id); Product product = em.find(Product.class, id);
model.addAttribute("products", List.of(product)); model.addAttribute("product", product);
return "/products.jsp"; return "/product.jsp";
} }
} }
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${product.productName}</title>
<link rel="stylesheet" type="text/css" href="/styl.css"/>
</head>
<body>
<h1>Informacje o produkcie ${product.productId}</h1>
<div class="product">
<p>Towar <a href="/products/${product.productId}" class="product-name">${product.productName}</a></p>
<p>Cena: <span class="product-price">${product.price}</span></p>
<p>Stawka VAT: <span class="product-price">${product.vat * 100}%</span></p>
<p class="product-description">${product.description}</p>
</div>
<p><a href="/products">Przejdź do listy produktów</a></p>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment