jsp中实现批量删除(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:33 点击:次
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
PrintWriter out=response.getWriter();
String[] selectdelete = request.getParameterValues("selectdelete");
String ids ="";
for(int i=0;i<selectdelete.length;i++){
ids += "'"+selectdelete[i]+"'";
if(i!=selectdelete.length-1) ids+=",";
}
String sql = "delete from COMMON where id in ("+ids+")";
Connection con = null;
Statement dodel = null;
DBcon dbcon = new DBcon();
try
{
con = dbcon.getConn();
dodel = con.createStatement();
dodel.executeUpdate(sql);
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
out.print("<script language='javascript'>alert('Do Success');window.location.href='delete.jsp';</script>");
out.flush();
out.close();
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>