java删除用户信息

阅读 41

2023-09-18

package com.yh.controller;

import com.yh.service.CustomerService;
import com.yh.service.impl.CustomerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/DeleteByIDServlet")
public class DeleteByIDServlet extends ViewBaseServlet{
    CustomerService customerService=new CustomerServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int id = Integer.parseInt(request.getParameter("id"));
        boolean b = customerService.deleteService(id);
        if (b){
            //重定向
            response.sendRedirect(request.getContextPath()+"QueryPageCustomerServlet");
        }else {
            request.getRequestDispatcher("404error").forward(request,response);
        }
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}

精彩评论(0)

0 0 举报