---
title: "在jsp中如何利用checkbox进行批量删除记录"
author: "srj2903"
date: "2009-03-12T21:38:11Z"
tags: []
slug: "jsp-checkbox"
draft: false
lastmod: "2009-03-12T21:38:11Z"
id: 348302
url: "https://srj2903.iteye.com/blog/348302"
---

在jsp中如何利用checkbox进行批量删除记录
在jsp中如何利用checkbox进行批量删除记录?
 NO.1  将前台jsp页面中的所有你要用到checkbox的name值设为相同如   
 <input   type="checkbox"   name="userid">   
 然后在后台获取参数时使用:   
 String   userid     =   request.getParameterValues("userid");   
 String   userIdAll   =   "";   
 if   (userid!=null)   {   
          for(int   i=0;i<userid.length;i++)  
{   
         userIdAll   =userIdAll   +   userid*   +   ","   ;   
         }   
          userIdAll   =   userIdAll.substring(0,   userIdAll.length-1   )   
          String   sql   =   "delete   reguser   where   userid   in("   +   userIdAll+   ")";   
          //执行sql语句略......   
  }   
NO.2   
String   box   =   request.getParameterValues("checkbox");//取得ID数组，checkbox放ID值；   
  int   UserID   =   ExStr.strArray2IntArray(box);//如有必要转换成int数组,ExStr是我自己定义的字符串处理的类；   
  再调用delete的sql语句……   
NO.3  
就用简单的sql语句就可以实现了。    
  String   id   =   request.getParameter("id");  
  String   sql   =   "delete   from   table   where   id   in   ("+   id   +");