28 lines
836 B
Java
28 lines
836 B
Java
|
package example.controller;
|
||
|
|
||
|
import example.dao.UserDao;
|
||
|
|
||
|
import javax.servlet.ServletException;
|
||
|
import javax.servlet.annotation.WebServlet;
|
||
|
import javax.servlet.http.HttpServlet;
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
@WebServlet("/deleteUserServlet")
|
||
|
public class DeleteUserServlet extends HttpServlet {
|
||
|
|
||
|
UserDao userDao=new UserDao();
|
||
|
|
||
|
@Override
|
||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||
|
String id = req.getParameter("id");
|
||
|
try {
|
||
|
userDao.deleteUser(Integer.parseInt(id));
|
||
|
req.getRequestDispatcher("/user?action=list").forward(req,resp);
|
||
|
} catch (Exception e) {
|
||
|
throw new RuntimeException(e);
|
||
|
}
|
||
|
}
|
||
|
}
|