Java 实战项目锤炼之在线蛋糕商城系统的实现
一、项目简述
功能: 主页显示热销商品;所有蛋糕商品展示,可进行商品搜 索;点击商品进入商品详情页,具有立即购买和加入购物 车功能,可增减购买商品数量亦可手动输入(同时验证库 存),热销商品展示。立即购买进入确认订单页面,可选择 已经添加的地址,亦可新增地址。(同时验证库存),可选 择购买哪些商品,可删除不需要的商品。点击结算进入确 认订单页面,确认后提交订单。后台管理:(修改密码 等),商品管理(商品批量添加、上下架等),订单管理。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe ( IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP + C3P0+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload
用户登录模块代码:
用户登录模块: @WebServlet(name = "user_login",urlPatterns = "/user_login") public class UserLoginServlet extends HttpServlet { private UserService uService = new UserService(); protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String ue = request.getParameter("ue"); String password = request.getParameter("password"); User user = uService.login(ue, password); if(user==null) { request.setAttribute("failMsg", "用户名、邮箱或者密码错误,请重新登录!"); request.getRequestDispatcher("/user_login.jsp").forward(request, response); }else { request.getSession().setAttribute("user", user); request.getRequestDispatcher("/user_center.jsp").forward(request, response); } } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
管理员添加用户代码:
管理员添加用户: @WebServlet(name = "admin_user_add",urlPatterns = "/admin/user_add") public class AdminUserAddServlet extends HttpServlet { private UserService uService = new UserService(); /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = new User(); try { BeanUtils.copyProperties(user, request.getParameterMap()); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(uService.register(user)) { request.setAttribute("msg", "客户添加成功!"); request.getRequestDispatcher("/admin/user_list").forward(request, response); }else { request.setAttribute("failMsg", "用户名或邮箱重复,请重新填写!"); request.setAttribute("u",user); request.getRequestDispatcher("/admin/user_add.jsp").forward(request, response); } } }
到此这篇关于Java 实战项目锤炼之在线蛋糕商城系统的实现 的文章就介绍到这了,更多相关Java 蛋糕商城系统内容请搜索自由互联以前的文章或继续浏览下面的相关文章希望大家以后多多支持自由互联!
【文章出处:美国多ip服务器】