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

📄 delete.java

📁 java web开发宝典源代码
💻 JAVA
字号:
package com.yxq.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

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

import com.yxq.bean.SingleObject;

public class Delete extends HttpServlet {
	private Map havemap=new HashMap();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session=request.getSession();
		Map carmap=(HashMap)session.getAttribute("carmap");
		String select[]=request.getParameterValues("car_selected");
		if(select==null||select.length==0){}
		else{
			havemap=(HashMap)session.getServletContext().getAttribute("havemap");
			if(havemap!=null&&havemap.size()!=0){
				synchronized(havemap){
					for(int i=0;i<select.length;i++){
						SingleObject carsingle=(SingleObject)carmap.get(Integer.valueOf(select[i]));
						havemap.put(carsingle.getId(),((Integer)(havemap.get(Integer.valueOf(select[i])))+carsingle.getBuyN()));
						session.getServletContext().setAttribute("havemap",havemap);
						carmap.remove(Integer.valueOf(select[i]));								
					}            			  
				}
				session.setAttribute("carmap",carmap);            		  
			}
		}
		RequestDispatcher rd=request.getRequestDispatcher("/templet.jsp");
		rd.forward(request,response);		
	}
}

⌨️ 快捷键说明

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