实习14
删除
代码结构
与上一个相比多了
DeleteServlet
package com.zhongruan.servlet;
import com.zhongruan.service.UserService;
import com.zhongruan.service.impl.UserServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class DeleteServlet extends HttpServlet {UserService userService=new UserServiceImpl();
@Override
protected void doGet(HttpServletRequest requst, HttpServletResponse respost) throws ServletException, IOException {
String ids=requst.getParameter("id");
int sid=Integer.parseInt(ids);
userService.delete(sid);
requst.getRequestDispatcher("/find").forward(requst,respost);
}
}