Commit 0f9ff0c1 by Patryk Czarnik

Wypisywanie błędów SQL w razie wystąpienia

parent 2adddba3
......@@ -90,8 +90,12 @@ public class ProductController {
// Spring sam wpisze dane do pól o takich samych nazwach.
// Taki parametr od razu staje się częścią modelu (to jest tzw. ModelAttribute)
// i nie trzeba dodawać go w osobnym poleceniu.
productRepository.save(product);
try {
productRepository.save(product);
model.addAttribute("saved", true);
} catch(Exception e) {
model.addAttribute("errors", List.of(e.toString()));
}
return "product_form";
}
......
......@@ -46,7 +46,7 @@ h2, h3, h4 {
.error {
color: red;
border: 4px solid red;
margin: 1em 0;
margin: 1em 400px 1em 50px;
padding: 1em;
background-color: white;
font-weight: bold;
......@@ -55,7 +55,7 @@ h2, h3, h4 {
.info {
color: green;
border: 4px solid green;
margin: 1em 0;
margin: 1em 400px 1em 50px;
padding: 1em;
background-color: white;
font-weight: bold;
......
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