Ordering system (java-based, database, jsp, servlet)

1 Home (login, registration)

(1) Display Time:

var time=new Date();
var year=time.getFullYear();
var month=time.getMonth();
var date=time.getDate();
var day=time.getDay();

(2) Log:

 

 Submitted after the user submits the data via a form login, servlet get to the data of the data to the Dao layer, information of the user Dao layer query by a user name and password, if not the queried user information qualifying, then it proves that there is no user there is, if there is information about the user, is divided into two cases, namely: the user's identity for consumers or businesses, according to the above three cases, servlet will be based on the results returned were redirected to a different page.

(3) Registration:

 

 First through the front of the form validation of user input to determine: is empty, the password meets the criteria, the two passwords are the same ...

After successful verification form can submit data to a form of the Servlet, Servlet invocation layer Dao, insertion operation, are displayed according to the corresponding information presentation will be successful after insertion returns the corresponding value, Servlet determines the return value.

2, shopping cart

(1) get all the product information:

 

 After the need to add a shopping cart when the need to look at all the merchandise, pick your favorite product was added to the shopping cart, therefore, need to submit a request to the servlet through jsp, servlet heavy dao layer to obtain product information encapsulated in the request domain to forward the request the form of the commodity information display in the jsp page.

(2) view product details:

 

 在展示商品全部信息的页面,点击相应的商品在页面获取该商品的ID并作为参数提交给Servlet,Servlet将该商品的ID作为Dao层的函数的参数,最终通过Dao层的sql语句,查询到对应商品的详细信息,请求转发到页面进行显示。

(3)添加购物车:

 

 在商品的详细信息页面点击添加后,将对应商品的ID提交给了Servlet,Servlet会去查看session是否为空,如果为空,则需要通过Dao层获取到对应ID的商品的信息,将商品信息和商品在购物车中的数量(初始值为 0)封装在一个vo中,然后将该类的对象放到map集合,键为商品的ID,最后,将map集合放到session中。在购物车不为空的情况下,又分为两种情况:购物车里面已经有相同ID的商品数据了,此时,字需要将商品数量加1即可,另外一种情况是:购物车里面还没有相同ID的商品数据,则需要通过Dao层获取到对应ID的商品的信息,将商品信息和商品在购物车中的数量(初始值为 0)封装在一个vo中,然后将该类的对象放到map集合,键为商品的ID,最后,将map集合放到session中。

(4)查看购物车:

采用foreach语句来遍历session中的购物车中所有商品的信息和数量进行页面的显示,最后,还需要对所有商品遍历,求出购物车商品的总额并进行页面显示。

3、订单

(1)提交订单:

 

 先将用户地址等详细信息写入数据库,如果成功插入数据,则将订单的简略信息写入到数据库,如果成功跳转到成功的页面,失败进入失败页面。

(2)订单信息:

 

 从cookie中获取登录时的用户名,从Session获取订单的商品名和商品的数量,通过Servlet,提交给Dao写入到数据库。

4、商家

(1)查看订单信息:

 

 (2)接单

 

 这里对数据库执行的是更新操作,即,修改订单的状态。

5、session、cookie、pagecontext的使用

(1)session在这里用于存储添加在购物车中的商品信息,在添加到session之前,需要将信息封装到map集合中。

(2)cookie在这里用于存储登录成功的用户名,便于根据用户的用户名查找该用户的订单信息。

(3)pagecontext只能用于当前页面的范围,超过这个页面就不能使用了。

 

Guess you like

Origin www.cnblogs.com/zhai1997/p/12318776.html