📄 clearshopcartservlet.java
字号:
package shop;
import java.io.IOException;
import java.util.Vector;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public final class ClearShopCartServlet extends HttpServlet{
public ClearShopCartServlet(){
super();
}
public void init(ServletConfig config)throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession();
Vector shopCartList=(Vector)session.getAttribute(Constants.SHOPCART_KEY);
if(shopCartList!=null){
shopCartList.clear();
session.setAttribute(Constants.SHOPCART_KEY,shopCartList);
}
resp.sendRedirect("basket_OK.jsp");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -