还是checkbox的问题。怎么在ACCESS中批删数据?看不懂
看了挺多的回答,但没弄明白。他们说批量删除需要NAME属性相同,但是name是字符数组型的吗?选择后提交出去是什么形式的?怎么可能用request.getParameter( "productId ");多次取得,并在数据库里执行多个删除?
还有个回答是说 "delete news where id in ( " & deleteid & ") "但是写进Deleteservlet后编译不出来。
麻烦帮我改改,实在找不到答案。谢谢了
************************
deleteProduct.jsp
*********************************************************************
<form action= "/wy/servlet/DeteleServlet " method= "POST ">
<table width=80% border= "1 " bgcolor= "#0099CC ">
<tr bgcolor= "#009966 " bordercolor= "#990066 ">
<td> id </td> <td> 类别 </td> <td> 名称 </td> <td> 出厂商 </td> <td> 价格 </td> <td> 描述 </td> <td> 删除 </td>
<%
request.setCharacterEncoding( "gb2312 ");
response.setContentType( "text/html; charset=gb2312 ");
Collection products=product.getAllProduct();
Iterator it=products.iterator();
while(it.hasNext()){
Product temp=(Product)it.next();
out.println( " <tr> <td> "+temp.getProductId()+ " </td> ");
out.println( " <td> "+temp.getCategoryId()+ " </td> ");
try
{
out.println( " <td> "+trans(temp.getName())+ " </td> ");
out.println( " <td> "+trans(temp.getProducer())+ " </td> ");
out.println( " <td> "+temp.getPrice()+ " </td> ");
out.println( " <td> "+trans(temp.getDescription())+ " </td> ");
out.println( " <td> <input type=\ "Checkbox\ " name= "+temp.getProductId()+ " value= "+temp.getProductId()+ "> </td> ");
}
catch(Exception e){}
}
%>
<br> <tr> <td> <input type= "submit " value= "提交 "> </td> </tr>
</table>
</form>
*********************************************************************
DeteleServlet.java
************************
package myservlet;
import java.io.*;
import
javax.servlet.ServletException;
import javax.servlet.http.*;
import java.sql.*;
import com.jspdev.ch12.*;
import com.jspdev.util.*;
public class DeteleServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException {
request.setCharacterEncoding( "gb2312 ");
response.setContentType( "text/html;charset=gb2312 ");
PrintWriter out=response.getWriter();
String productId=request.getParameter( "productId ");
try{
//下面为写入数据库
ProductBean aduB=new ProductBean();