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

📄 controller.java

📁 网上书店网站源代码
💻 JAVA
字号:
package bookshop.bean;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class Controller extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=GB2312";

    //Initialize global variables
    public void init() throws ServletException {
    }
    public void init(ServletConfig config) throws ServletException
    {
        super.init(config);
    }

    //Process the HTTP Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();

    }

    //Process the HTTP Post request
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws
            ServletException, IOException {

        String command=req.getParameter("command");
        HttpSession session=req.getSession();
        FurnitureCart cart=(FurnitureCart)session.getAttribute("cart");
        if(command.equals("add"))
        {
            String id=req.getParameter("id");
            if(id!=null)
            {
                String b_name=req.getParameter("name");
                Float b_price=new Float(req.getParameter("b_price"));
                int quanlity=new Integer(req.getParameter("quanlity"));
                cart.addItem(id,b_name,b_price.floatValue(),quanlity);
            }
        }
        res.sendRedirect("/bookshop/main.jsp");
    }

    //Clean up resources
    public void destroy() {
    }
}

⌨️ 快捷键说明

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