批量删除后不能跳转到list页面,单个删除后却可以
package com.imooc.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.imooc.service.MaintainService;
@SuppressWarnings("serial")
public class DeleteBatchServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
//设置编码
req.setCharacterEncoding("UTF-8");
//初始化服务
MaintainService maintainService=new MaintainService();
//接受页面的值
String[] ids=req.getParameterValues("id");
maintainService.deleteBatch(ids);
//在上面用jdbc把数据库取出来之后放在messageList里面,然后就可以转发了,转发到由req带到前台去使用请求转发,就是servlet那里传过来的请求会直接转给这个页面来处理
//下面两行中第二行是错的,直接跳是不行的,因为没有查询数据的过程
req.getRequestDispatcher("/List.action").forward(req, resp);
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
this.doGet(req, resp);
}
}