Commit 19d90a5f by Patryk Czarnik

missing_product

parent a7a0531a
...@@ -30,9 +30,11 @@ public class ProductController { ...@@ -30,9 +30,11 @@ public class ProductController {
Optional<Product> product = productRepository.findById(productId); Optional<Product> product = productRepository.findById(productId);
if(product.isPresent()) { if(product.isPresent()) {
model.addAttribute("product", product.get()); model.addAttribute("product", product.get());
}
return "product"; return "product";
} else {
model.addAttribute("product_id", productId);
return "missing_product";
}
} }
} }
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Brak towaru ${product_id}</title>
<link rel="stylesheet" type="text/css" href="/styl.css" />
</head>
<body>
<h1>Brak towaru ${product_id}</h1>
<div class="error">Niestety, nie udało się znaleźć produktu o numerze ${product_id}.</div>
</body>
</html>
...@@ -16,6 +16,8 @@ public interface Repository5 extends JpaRepository<Employee, Integer> { ...@@ -16,6 +16,8 @@ public interface Repository5 extends JpaRepository<Employee, Integer> {
List<Employee> findByLastName(String name); List<Employee> findByLastName(String name);
List<Employee> findByLastNameContainingIgnoringCase(String name);
List<Employee> findByJob_JobId(String jobId); List<Employee> findByJob_JobId(String jobId);
// employee.getDepartment().getLocation().getCity() // employee.getDepartment().getLocation().getCity()
......
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