• 大小: 23KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: Java
  • 标签: jsp购物车  源代码  

资源简介

jsp购物车 jsp购物车源代码 eclipse开发

资源截图

代码片段和文件信息

package com.buat.controller.shopping;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.buat.model.shoppingDAO.Products;
import com.buat.model.shoppingDAO.shoppingDAO;
import com.buat.pagination.*;
public class shopping extends HttpServlet {
private ServletConfig config = null;
public shopping() {
super();
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
this.config = config;
}
public void destroy() {
super.destroy(); // Just puts “destroy“ string in log

}

public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
this.doPost(request response);
}

public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
String url = null;
String operationType = null;
operationType = request.getParameter(“operationType“);
if(operationType.equals(“queryAllProducts“)){
url = this.queryAllProducts(request response);
}else if(operationType.equals(“buyProducts“)){
url = this.buyProducts(request response);
}
RequestDispatcher dispatcher = null;
dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request response);
}

public void init() throws ServletException {

}
public String queryAllProducts(HttpServletRequest request HttpServletResponse response){
String url = null;
int [] resultForm = null;
Products products = new Products();
shoppingDAO dao = new shoppingDAO();
ArrayList productsList = dao.queryAll();
resultForm = Pagination.getIndex(productsList);
request.getSession().setAttribute(“resultForm“ resultForm);
request.setAttribute(“productsList“productsList);
url = “/Shopping.jsp“;
return url;
}
public String buyProducts(HttpServletRequest request HttpServletResponse response){
String url = null;

Products products [] = null;
String id [] = request.getParameterValues(“productId“);
System.out.println(“idLength: “+id.length);
String[] productName = request.getParameterValues(“productName“);
String[] productPrice = request.getParameterValues(“productPrice“);
String[] willBuy = request.getParameterValues(“willBuy“);
if(id.length>0){
products = new Products[id.length];
for(int i =0;i products[i]=new Products(Integer.parseInt(String.valueOf(id[i]))productName[i]productPrice[i]Integer.parseInt(String.valueOf(willBuy[i])));
System.out.println(“id [“+i+“]=“+id[i]);
}
ArrayList buyList = (ArrayList)request.getSession().getAttribute(“buyList“);
if(buyList

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        450  2007-02-04 12:58  购物车\.classpath

     文件        297  2007-02-04 12:43  购物车\.mymetadata

     文件       1226  2007-02-04 15:29  购物车\.project

     文件        785  2007-02-05 14:32  购物车\WebRoot\Login.jsp

     文件        913  2007-02-05 14:32  购物车\WebRoot\MyCart.jsp

     文件        704  2007-02-05 14:32  购物车\WebRoot\ProccessLogin.jsp

     文件       1185  2007-02-05 14:32  购物车\WebRoot\Register.jsp

     文件        378  2007-02-05 14:32  购物车\WebRoot\registResult.jsp

     文件       2585  2007-02-06 12:08  购物车\WebRoot\Shopping.jsp

     文件       1144  2007-02-04 14:06  购物车\WebRoot\WEB-INF\web.xml

     文件        701  2007-02-06 10:24  购物车\WebRoot\WEB-INF\classes\com\buat\pagination\Pagination.class

     文件       1616  2007-02-04 14:04  购物车\WebRoot\WEB-INF\classes\com\buat\model\userDAO\registInfo.class

     文件       2970  2007-02-04 17:37  购物车\WebRoot\WEB-INF\classes\com\buat\model\userDAO\userDAO.class

     文件       1152  2007-02-04 14:04  购物车\WebRoot\WEB-INF\classes\com\buat\model\userDAO\userInfo.class

     文件       1377  2007-02-04 20:01  购物车\WebRoot\WEB-INF\classes\com\buat\model\shoppingDAO\Products.class

     文件       2144  2007-02-05 16:28  购物车\WebRoot\WEB-INF\classes\com\buat\model\shoppingDAO\shoppingDAO.class

     文件       1535  2007-02-04 13:12  购物车\WebRoot\WEB-INF\classes\com\buat\linkdatabase\linkDatabase.class

     文件       3730  2007-02-04 17:14  购物车\WebRoot\WEB-INF\classes\com\buat\controller\user\user.class

     文件       4696  2007-02-06 10:28  购物车\WebRoot\WEB-INF\classes\com\buat\controller\shopping\shopping.class

     文件         39  2007-02-04 12:43  购物车\WebRoot\meta-INF\MANIFEST.MF

     文件        443  2007-02-06 10:24  购物车\src\com\buat\pagination\Pagination.java

     文件        939  2007-02-04 14:04  购物车\src\com\buat\model\userDAO\registInfo.java

     文件       2192  2007-02-04 17:37  购物车\src\com\buat\model\userDAO\userDAO.java

     文件        636  2007-02-04 14:04  购物车\src\com\buat\model\userDAO\userInfo.java

     文件        761  2007-02-04 20:01  购物车\src\com\buat\model\shoppingDAO\Products.java

     文件       1074  2007-02-05 16:28  购物车\src\com\buat\model\shoppingDAO\shoppingDAO.java

     文件        930  2007-02-04 13:12  购物车\src\com\buat\linkdatabase\linkDatabase.java

     文件       2954  2007-02-04 17:14  购物车\src\com\buat\controller\user\user.java

     文件       3755  2007-02-06 10:28  购物车\src\com\buat\controller\shopping\shopping.java

     文件        426  2007-02-04 22:46  购物车\db\shopping.sql

............此处省略32个文件信息

评论

共有 条评论