⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clientshowoneorderlistaction.java

📁 电子商务网站使用MVC模式B/S结构功能不是很全适合初学者看
💻 JAVA
字号:
package Client;
import java.io.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import Common.DBConnectBean;

public class clientShowOneOrderListAction extends HttpServlet{
	public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
		ServletContext application=getServletConfig().getServletContext(); 
		request.setCharacterEncoding("gb2312");
		HttpSession session=request.getSession();
		String username=(String)session.getAttribute("username".toUpperCase());
		////////////////////System.out.println("这个没打印");
		if(username==null){
			application.getRequestDispatcher("/client/clientList.jsp?logged=false").forward(request,response);	
		}
		String orderID=request.getParameter("orderID");
		//获取现在客户的购物车里的所有商品的信息及数量
		DBConnectBean dbBean=new DBConnectBean("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:shopping","","");
		//如果客户已经买了该商品,则添加商品数量
		String addDay="",card="",totalPrice="",num="",picture="",price="",commodityNum="";
	
		ArrayList userOrderList=new ArrayList();
		ArrayList orderDetail=dbBean.getAllRecord("select * from orders where orderID='"+orderID+"'");
		for(int i=0;i<orderDetail.size();i++){
			Hashtable temptable=(Hashtable)orderDetail.get(i);
			Hashtable table=new Hashtable();
		
			card=temptable.get("card".toUpperCase()).toString();
			num=temptable.get("num".toUpperCase()).toString();
			picture=temptable.get("picture".toUpperCase()).toString();
			price=temptable.get("price".toUpperCase()).toString();
			commodityNum=temptable.get("commodityNum".toUpperCase()).toString();
			
			table.put("card".toUpperCase(),card);
			table.put("num".toUpperCase(),num);
			table.put("picture".toUpperCase(),picture);
			table.put("price".toUpperCase(),price);
			table.put("commodityNum".toUpperCase(),commodityNum);
			userOrderList.add(table);
		}
		//如果可户还未买该商品,则添加新商品
		session.setAttribute("userOrderList".toUpperCase(),userOrderList);
		application.getRequestDispatcher("/client/clientShowOneOrderList.jsp").forward(request,response);
	}
	public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
	   	doGet(request,response);
	}
}
	
	
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -