每日总结 4.5

今天进行了贩卖机的模拟,

 

 实现购买之后减一,点击补货后全部成为满货状态。

package res;

import java.io.IOException;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@WebServlet("/Sere")
public class Serve extends HttpServlet{
    Daos d=new Daos();
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        String method=request.getParameter("method");
        switch (method){
        case "findAll":
            String num=request.getParameter("num");
            Integer i=Integer.parseInt(num)-1;
            String num1=String.valueOf(i);
            String name="可乐";
            d.find(name, num1);
            request.getRequestDispatcher("top.jsp").forward(request, response);
        case "find":
            String nums=request.getParameter("num");
            Integer is=Integer.parseInt(nums)-1;
            String nums1=String.valueOf(is);
            String names=request.getParameter("name");
            d.finds(names, nums1);
            request.getRequestDispatcher("top1.jsp").forward(request, response);
        case "bh":
            String numse=request.getParameter("numz");
            String namese=request.getParameter("name");
            String numses=request.getParameter("numzs");
            String nameses=request.getParameter("names");
            d.finds(namese, numse);
            d.finds(nameses, numses);
            request.getRequestDispatcher("top1.jsp").forward(request, response);
    }
    }
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        doPost(request,response);
}
}

 

posted @ 2023-04-05 22:24  一个小虎牙  阅读(12)  评论(0编辑  收藏  举报