Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_dzienna_15_09
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_dzienna_15_09
Commits
19d90a5f
Commit
19d90a5f
authored
Oct 05, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
missing_product
parent
a7a0531a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
ProductController.java
...ing/src/main/java/sklep/controller/ProductController.java
+4
-2
missing_product.jsp
...ing/src/main/webapp/WEB-INF/templates/missing_product.jsp
+15
-0
Repository5.java
...znie/src/main/java/com/example/demo/data/Repository5.java
+2
-0
No files found.
PC30-SklepSpring/src/main/java/sklep/controller/ProductController.java
View file @
19d90a5f
...
@@ -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"
;
}
else
{
model
.
addAttribute
(
"product_id"
,
productId
);
return
"missing_product"
;
}
}
return
"product"
;
}
}
}
}
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/missing_product.jsp
0 → 100644
View file @
19d90a5f
<
%@
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>
PC31-SpringTechnicznie/src/main/java/com/example/demo/data/Repository5.java
View file @
19d90a5f
...
@@ -15,6 +15,8 @@ import com.example.demo.model.Employee;
...
@@ -15,6 +15,8 @@ import com.example.demo.model.Employee;
public
interface
Repository5
extends
JpaRepository
<
Employee
,
Integer
>
{
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment