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/student/DeleteSelectStudentServlet....

37 lines
1.3 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.student;
import service.StudentService;
import service.impl.StudentServiceImpl;
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("/deleteSelectStudentServlet")
// 删除选定学生的Servlet
public class DeleteSelectStudentServlet extends HttpServlet {
// 处理POST请求
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获取选定学生的ID数组
String[] sids = request.getParameterValues("sid");
// 创建学生服务的实例
StudentService service = new StudentServiceImpl();
// 调用服务方法删除选定的学生
service.deleteSelectStudent(sids);
// 重定向到查找学生的页面
response.sendRedirect(request.getContextPath() + "/findStudentByPageServlet");
}
// 处理GET请求直接调用doPost方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}