In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use JSP's Session mechanism to write shopping cart programs, I hope you will learn something after reading this article, let's discuss it together!
The commodity class built by one of the shopping carts based on JSP Session mechanism
◆ writes a Goods class and defines the various properties of the commodity, the method of returning the commodity property, and the method of comparing the commodity object.
◆ Goods.java
Package com.viita.Shop; public class Goods implements Comparable {
◆ initializes each member variable
Private String Id = the number of the null;// item Id private String name = the name of the null;// commodity name private float price = 0.00F / the price of the commodity price private int number = 0pm / the quantity of the commodity number public Goods (String Id, String name, float price, int number) {this.Id = Id; this.name = name; this.price = price; this.number = number } public String getId () / return the number of the ordered item Id {return this.Id;} public String getName () / / return the name of the ordered item name {return this.name;} public float getPrice () / / return the price of the ordered item price {return this.price;} public int getNumber () / / return the quantity of the ordered item number {return this.number } public int compareTo (Object m) {/ / TODO Auto-generated method stub Goods n = (Goods) m; int comRs = Id.compareTo (n.Id); return comRs;}}
The second realization of shopping cart based on JSP Session mechanism
◆ first establishes the Goods object goods, and establishes the ArrayList object ay
◆ adds the commodity object to the ArrayList object ay through the method add () of the ArrayList object
◆ because the ArrayList object has methods to add and delete members, multiple commodity stores are managed in the ArrayList object.
◆ stores ArrayList object ay in session object to realize shopping cart function.
◆ shopcar.jsp
JSP Session Mechanism Shopping cart III Delete goods
◆ deletes items from the shopping cart
◆ removeGoods.jsp
Does the JSP Session shopping cart brighten your eyes? Let's get started, the use of the JSP Session mechanism is looking forward to your try.
After reading this article, I believe you have a certain understanding of "how to write shopping cart programs with JSP's Session mechanism". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.