Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Summary Make a shopping cart using sessions for storage! This is easy stuff now that you've seen it done! Spend some time and make
Summary Make a shopping cart using sessions for storage! This is easy stuff now that you've seen it done! Spend some time and make it amazing when it works! Exercises Start with the storage. Create a Phone POJO capable of storing an id, a phone model, and a phone price. Lombok as needed. Create an index.html page where you display list from a session attribute representing any phones you hope to purchase. You know enough now to pull this off on your own! Remember, ${session. ...} to retrieve attributes from a session! Create a form on index.html bound to a phone (model) attribute. Your users should be able to easily enter info here about what they hope to purchase. Post from your form back to "/insertPhone" and use a ModelAttribute to retrieve your form data in a pre- populated Phone instance. In the "/insertPhone" mapped method, create an empty List . Check if your session isNew(). If it is new, initialize the list of phones so we can store future info in it! If the session is not new, get a (the?) list of phones you stored last time (coming up in a sec) out of it. Either way (new session or old), add the current info your user wishes to purchase to the list, then add the list to the session as an attribute again! Finish it off with a blank Phone in the model again so you can add another at your form! Things to watch for: This algorithm needs to line up with itself exactly in many of the same ways Spring does! If you create a varable phoneList, you must initialize a variable called phoneList or get an attribute and set your phoneList var equal to it. Similarly, the attribute name you get for your phoneList must exactly equal the attribute name you set for it a moment later if this is to work!
Step by Step Solution
★★★★★
3.55 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
Create Phone POJO using Lombok import lombokData Data public class Phone private Long id private Str...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started