You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
text/src/web/servlet/notify/DeleteNotifyServlet.java

41 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package web.servlet.notify;
import domain.Student;
import service.NotifyService;
import service.impl.NotifyServiceImpl;
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 javax.servlet.http.HttpSession;
import java.io.IOException;
/**
* 删除通知的Servlet
*/
@WebServlet("/deleteNotifyServlet")
public class DeleteNotifyServlet extends HttpServlet {
/**
* 处理POST请求删除指定ID的通知。
*
* @param request HTTP请求对象包含客户端发送的数据。
* @param response HTTP响应对象用于生成返回给客户端的响应。
* @throws ServletException 如果处理请求时发生错误。
* @throws IOException 如果输入或输出异常发生。
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 设置请求的字符编码为UTF-8以支持中文字符的正确处理
request.setCharacterEncoding("utf-8");
HttpSession session = request.getSession();
String notifyid = request.getParameter("id");
NotifyService service = new NotifyServiceImpl();
service.deleteNotifyById(notifyid);
request.getRequestDispatcher("/notifyListServlet").forward(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
}