本篇文章给大家分享的是有关如何Java分析家居购物商城系统,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
一、项目简述
功能: Java Web精品项目源码,家居商城分类展示,商品展示, 商品下单,购物车,个人中心,后台管理,用户管理,商品管理,分类管理等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: Jdbc+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload
打开订单列表页面代码:
@Controller@RequestMapping("/order")public class OrderController { @Autowired private OrderService orderService; @RequestMapping("/toList.html") public String toOrderList() { return "mall/order/list"; } @RequestMapping("/list.do") @ResponseBody public ResultBean<List<Order>> listData(HttpServletRequest request) { List<Order> orders = orderService.findUserOrder(request); return new ResultBean<>(orders); } @RequestMapping("/getDetail.do") @ResponseBody public ResultBean<List<OrderItem>> getDetail(int orderId) { List<OrderItem> orderItems = orderService.findItems(orderId); return new ResultBean<>(orderItems); } @RequestMapping("/submit.do") public void submit(String name, String phone, String addr, HttpServletRequest request, HttpServletResponse response) throws Exception { orderService.submit(name, phone, addr, request, response); } @RequestMapping("pay.do") @ResponseBody public ResultBean<Boolean> pay(int orderId, HttpServletResponse response) throws IOException { orderService.pay(orderId); return new ResultBean<>(true); } @RequestMapping("receive.do") @ResponseBody public ResultBean<Boolean> receive(int orderId, HttpServletResponse response) throws IOException { orderService.receive(orderId); return new ResultBean<>(true); } }
商品信息操作代码:
@Controller@RequestMapping("/product")public class ProductController { @Autowired private ProductService productService; @Autowired private ClassificationService classificationService; @Autowired private ShopCartService shopCartService; @RequestMapping("/get.do") public ResultBean<Product> getProduct(int id) { Product product = productService.findById(id); return new ResultBean<>(product); } @RequestMapping("/get.html") public String toProductPage(int id, Map<String, Object> map) { Product product = productService.findById(id); map.put("product", product); return "mall/product/info"; } @ResponseBody @RequestMapping("/hot.do") public ResultBean<List<Product>> getHotProduct() { List<Product> products = productService.findHotProduct(); return new ResultBean<>(products); } @ResponseBody @RequestMapping("/new.do") public ResultBean<List<Product>> getNewProduct(int pageNo, int pageSize) { Pageable pageable = new PageRequest(pageNo, pageSize); List<Product> products = productService.findNewProduct(pageable); return new ResultBean<>(products); } @RequestMapping("/category.html") public String toCatePage(int cid, Map<String, Object> map) { Classification classification = classificationService.findById(cid); map.put("category", classification); return "mall/product/category"; } @RequestMapping("/toCart.html") public String toCart(){ return "mall/product/cart"; } @ResponseBody @RequestMapping("/category.do") public ResultBean<List<Product>> getCategoryProduct(int cid, int pageNo, int pageSize) { Pageable pageable = new PageRequest(pageNo, pageSize); List<Product> products = productService.findByCid(cid, pageable); return new ResultBean<>(products); } @ResponseBody @RequestMapping("/categorySec.do") public ResultBean<List<Product>> getCategorySecProduct(int csId, int pageNo, int pageSize) { Pageable pageable = new PageRequest(pageNo, pageSize); List<Product> products = productService.findByCsid(csId, pageable); return new ResultBean<>(products); } @ResponseBody @RequestMapping("/getCategorySec.do") public ResultBean<List<Classification>> getCategorySec(int cid){ List<Classification> list = classificationService.findByParentId(cid); return new ResultBean<>(list); } @ResponseBody @RequestMapping("/addCart.do") public ResultBean<Boolean> addToCart(int productId, HttpServletRequest request) throws Exception { shopCartService.addCart(productId, request); return new ResultBean<>(true); } @ResponseBody @RequestMapping("/delCart.do") public ResultBean<Boolean> delToCart(int productId, HttpServletRequest request) throws Exception { shopCartService.remove(productId, request); return new ResultBean<>(true); } @ResponseBody @RequestMapping("/listCart.do") public ResultBean<List<OrderItem>> listCart(HttpServletRequest request) throws Exception { List<OrderItem> orderItems = shopCartService.listCart(request); return new ResultBean<>(orderItems); } }
以上就是如何Java分析家居购物商城系统,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注编程网行业资讯频道。