Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_weekendowa_20221008
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_weekendowa_20221008
Commits
42a90ba7
Commit
42a90ba7
authored
Nov 27, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Koszyk w wersji @SessionAttribute
parent
e88099ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
ProductController.java
...ing/src/main/java/sklep/controller/ProductController.java
+2
-2
No files found.
PC30-SklepSpring/src/main/java/sklep/controller/ProductController.java
View file @
42a90ba7
...
...
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.SessionAttribute
;
import
sklep.basket.Basket
;
import
sklep.model.Product
;
...
...
@@ -136,8 +137,7 @@ public class ProductController {
@GetMapping
(
"/{id}/add-to-basket"
)
public
String
addToBasket
(
@PathVariable
(
"id"
)
int
productId
,
HttpSession
sesja
)
{
Basket
basket
=
(
Basket
)
sesja
.
getAttribute
(
"basket"
);
@SessionAttribute
Basket
basket
)
{
Optional
<
Product
>
product
=
productRepository
.
findById
(
productId
);
if
(
product
.
isPresent
())
{
basket
.
addProduct
(
product
.
get
());
...
...
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