• 大小: 7.43MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-09
  • 语言: Java
  • 标签: servle  ajax  boostr  

资源简介

使用Bootstarp+Ajax+,jstl+jsp等技术制作页面+邮箱验证+分页 实现了用户登录,用户注册,用户信息修改,密码修改,地址添加,地址管理,添加商品,管理商品,订单管理

资源截图

代码片段和文件信息

package com.controller.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.pojo.Address;
import com.pojo.MyOrder;
import com.pojo.OrderItem;
import com.pojo.Product;
import com.pojo.User;
import com.service.OrderService;
import com.service.ProductService;

@WebServlet(“/AddOrderServlet“)
public class AddOrderServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
doPost(request response);
}

protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
System.out.println(“提交订单的servlet-------“);

String flag = request.getParameter(“flag“);
System.out.println(“请求的值“+flag);

switch (flag) {
case “addShop“:
addShop(request response);
break;
case “listOrder“:
listOrder(requestresponse);
break;
default:
break;
}


}

private void listOrder(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
String userId = request.getParameter(“userId“);
List listOrder = new OrderService().findAllOrder(userId);
if (listOrder != null && listOrder.size()>0) {
System.out.println(“第一个下单时间:“+listOrder.get(0).getOrderTime());
request.setAttribute(“listOrder“ listOrder);
request.getRequestDispatcher(“front/order.jsp?flag=listOrder“).forward(request response);
} else {
response.sendRedirect(request.getContextPath() + “/front/order.jsp“);
}
}

private void addShop(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
// TODO Auto-generated method stub
MyOrder order = new MyOrder();
// 把hashcode作为订单编号
int orderId = order.hashCode() + new Random().nextInt(100);
order.setOrderId(orderId);
// 创建订单集合
List ListOrderItem = new ArrayList<>();
HttpSession session = request.getSession();
// 获取选中的商品
String[] pIds = request.getParameterValues(“pid“);
// 获取对应的商品数量
String[] nums = request.getParameterValues(“buyNum“);
if (pIds != null && nums != null) {
// 商品总价
double totalMoney = 0;
for (int i = 0; i < pIds.length; i++) {
int pid = Integer.parseInt(pIds[i]);
// 通过id查询出对应的商品对象
Product pro = new ProductService().findProductById(pid);
int num = Integer.parseInt(nums[i]);
// 计算该商品的总价值
double singleMoney = pro.getTruePrice() * num;

OrderItem orderItem = new OrderItem(0 order pro num singleMoney);
System.out.prin

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-04-17 14:10  (小米商城)\
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\
     文件         920  2018-09-03 19:14  (小米商城)\FirstProject_AiMi\.classpath
     文件        1050  2018-09-04 21:33  (小米商城)\FirstProject_AiMi\.project
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\.settings\
     文件         567  2018-09-03 18:30  (小米商城)\FirstProject_AiMi\.settings\.jsdtscope
     文件          72  2018-09-09 10:51  (小米商城)\FirstProject_AiMi\.settings\org.eclipse.core.resources.prefs
     文件         364  2018-09-03 18:30  (小米商城)\FirstProject_AiMi\.settings\org.eclipse.jdt.core.prefs
     文件         503  2018-09-04 21:33  (小米商城)\FirstProject_AiMi\.settings\org.eclipse.wst.common.component
     文件         345  2018-09-03 18:30  (小米商城)\FirstProject_AiMi\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-09-03 18:30  (小米商城)\FirstProject_AiMi\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-09-03 18:30  (小米商城)\FirstProject_AiMi\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\build\
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\build\classes\
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\build\classes\com\
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\build\classes\com\controller\
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\
     文件        6164  2018-09-15 11:39  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\AddOrderServlet.class
     文件        5323  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\AddressServlet.class
     文件        2216  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\IndexServlet.class
     文件        3122  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\ManagerServlet.class
     文件        5484  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\ProductServlet.class
     文件        3912  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\ShopCarServlet.class
     文件        3867  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\SubTypeServlet.class
     文件        3293  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\SuperTypeServlet.class
     文件        8812  2018-09-15 14:18  (小米商城)\FirstProject_AiMi\build\classes\com\controller\controller\UserServlet.class
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\build\classes\com\controller\filter\
     文件        1355  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\controller\filter\EncodingFilter.class
     目录           0  2019-04-17 14:09  (小米商城)\FirstProject_AiMi\build\classes\com\dao\
     文件        3560  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\dao\AddressDAO.class
     文件        1365  2018-09-14 23:52  (小米商城)\FirstProject_AiMi\build\classes\com\dao\ManagerDAO.class
............此处省略402个文件信息

评论

共有 条评论