• 大小: 4.29MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-11
  • 语言: Java
  • 标签: 网上商城  java  eclipse  

资源简介

这个网上商城是以前做的实训项目,具有添加商品,然后还有结算等等功能

资源截图

代码片段和文件信息

package com.wd.controller;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
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.jsp.PageContext;

import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;

import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;
import com.wd.po.Goods;
import com.wd.service.IGoodsService;
import com.wd.service.impl.GoodsService;

/**
 * Servlet implementation class AddGoodsServlet
 */
@WebServlet(“/AddGoodsServlet“)
public class AddGoodsServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
 File tmpDir = null;//初始化上传文件的临时存放目录  
    File saveDir = null;//初始化上传文件后的保存目录  
    public AddGoodsServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

/**
 * @see HttpServlet#doGet(HttpServletRequest request HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
doPost(request response);
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
request.setCharacterEncoding(“utf-8“);
response.setContentType(“text/html;charset=utf-8“);

String good_name=request.getParameter(“good_name“);
String good_type=request.getParameter(“good_type“);
String good_discount=request.getParameter(“good_discount“);
String good_price=request.getParameter(“good_price“);
String good_desc=request.getParameter(“good_desc“);
String supplier=request.getParameter(“supplier“);
String ispreferred=request.getParameter(“ispreferred“);
String qty=request.getParameter(“qty“);
String good_pic=request.getParameter(“good_pic“);
good_pic=“img/goodspu/“+good_pic;

Goods og =new Goods();
og.setGood_desc(good_desc);
og.setGood_discount(good_discount);
og.setGood_name(good_name);
og.setGood_pic(good_pic);
og.setGood_price(good_price);
og.setGood_type(good_type);
og.setIspreferred(ispreferred);
og.setQty(qty);
og.setSupplier(supplier);

IGoodsService ig=new GoodsService();
if (ig.addGoods(og)) {
response.getWriter().println(“添加成功“);
} else {
response.getWriter().println(“添加失败“);

}


/*SmartUpload su = new SmartUpload();//新建一个SmartUpload对象
//su.getRequest

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1091  2017-09-17 20:59  Eshop\.classpath
     文件        1057  2017-09-17 20:59  Eshop\.project
     目录           0  2017-09-18 20:19  Eshop\.settings\
     文件         564  2017-09-17 20:59  Eshop\.settings\.jsdtscope
     文件         143  2017-09-17 20:59  Eshop\.settings\org.eclipse.core.resources.prefs
     文件         364  2017-09-17 20:59  Eshop\.settings\org.eclipse.jdt.core.prefs
     文件         480  2017-09-17 20:59  Eshop\.settings\org.eclipse.wst.common.component
     文件         412  2017-09-17 20:59  Eshop\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2017-09-17 20:59  Eshop\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2017-09-17 20:59  Eshop\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2017-09-18 20:19  Eshop\src\
     目录           0  2017-09-18 20:19  Eshop\src\com\
     目录           0  2017-09-18 20:19  Eshop\src\com\wd\
     目录           0  2017-09-18 20:19  Eshop\src\com\wd\controller\
     文件        5546  2017-09-17 20:59  Eshop\src\com\wd\controller\AddGoodsServlet.java
     文件        2267  2017-09-17 20:59  Eshop\src\com\wd\controller\AddOrderServlet.java
     文件        2218  2017-09-17 20:59  Eshop\src\com\wd\controller\AddShoppingCartServlet.java
     文件        1975  2017-09-17 20:59  Eshop\src\com\wd\controller\ChangePWDServlet.java
     文件        1723  2017-09-17 20:59  Eshop\src\com\wd\controller\DeleteCartServlet.java
     文件        1546  2017-09-17 20:59  Eshop\src\com\wd\controller\DeleteUserServlet.java
     文件        2863  2017-09-17 20:59  Eshop\src\com\wd\controller\GoodsShowServlet.java
     文件        1803  2017-09-17 20:59  Eshop\src\com\wd\controller\LoginServlet.java
     文件        1207  2017-09-17 20:59  Eshop\src\com\wd\controller\LogoutServlet.java
     文件        2416  2017-09-17 20:59  Eshop\src\com\wd\controller\QueryGoodsServlet.java
     文件        2689  2017-09-17 20:59  Eshop\src\com\wd\controller\QueryOrderServlet.java
     文件        3065  2017-09-17 20:59  Eshop\src\com\wd\controller\QueryShoppingCartServlet.java
     文件        2579  2017-09-17 20:59  Eshop\src\com\wd\controller\QueryUserServlet.java
     文件        2956  2017-09-17 20:59  Eshop\src\com\wd\controller\RegisterServlet.java
     文件        2844  2017-09-17 20:59  Eshop\src\com\wd\controller\UpdateUserServlet.java
     目录           0  2017-09-18 20:19  Eshop\src\com\wd\dao\
     文件         389  2017-09-17 20:59  Eshop\src\com\wd\dao\IGoodsDao.java
............此处省略171个文件信息

评论

共有 条评论