Topic: JSP连接数据库出现问题,向大家请教,谢谢! |
Print this page |
1.JSP连接数据库出现问题,向大家请教,谢谢! | Copy to clipboard |
Posted by: Bluebluesea Posted on: 2007-04-12 22:59 JSP中连接数据库又出现了问题,向大家请教 (deletepro.jsp): id 类别 名称 出厂商 价格 描述 删除 (表格字段) dddd english ddddd dddddd 22.0 ddddd 删除 (表格内容) isbn-4-6 computer J2EE企业级应用开发 电子工业出版 56.0 还不错 删除 (表格内容) 现在是想点表格内容中的"删除"就可以转向"deletepro_do.jsp"实现删除其一行 比如点第一个表格内容中的删除,则删除id="dddd"的一行,"id"是主键 deletepro.jsp主要代码: <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %> <jsp:useBean id="db" scope="page" class="demo.openDB" /> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>删除商品</title> <style type="text/css"> <!-- .STYLE2 {color: #FFFFFF} --> </style> </head> <body> <br><br><br> <center> <font size="+5" face="华文隶书">删除一个商品</font> </center> <br><br><br><br> <center> <table bgcolor="#FF6666"> <tr> <td width="100">id</td> <td width="100" align="center">类别</td> <td width="200" align="center">名称</td> <td width="150" align="center">出厂商</td> <td width="100" align="center">价格</td> <td width="150" align="center">描述</td> <td width="50" align="center">删除</td> </tr> <% Connection conn=db.getConnection(); String sql="select * from products"; Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery(sql); while(rs.next()){ %> <tr> <td bgcolor="#FFDD33"><%=rs.getString("productid")%></td> <td bgcolor="#FFFF00"><%=rs.getString("category")%></td> <td bgcolor="#99CC00"><%=rs.getString("name")%></td> <td bgcolor="#FFCC99"><%=rs.getString("producer")%></td> <td bgcolor="#88FFDD"><%=rs.getFloat("price")%></td> <td bgcolor="#DDFC88"><%=rs.getString("descn")%></td> <td bgcolor="#6633FF" align="center"><span class="STYLE2"><a href="deletepro_do.jsp"> 删除</a></span></td> </tr> <%}%> </table> <br> <br><br><br> <a href="goodmain.jsp">返回</a> </center> </body> </html> deletepro_do.jsp主要代码: <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %> <jsp:useBean id="db" scope="page" class="demo.openDB" /> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>删除商品</title> <style type="text/css"> <!-- .STYLE2 {color: #FFFFFF} --> </style> </head> <body> <br><br><br> <center> <font size="+5" face="华文隶书">删除一个商品</font> </center> <br><br><br><br> <% String id=request.getParameter(Products); Connection conn=db.getConnection(); Statement stmt=conn.createStatement(); String sql="delete from products where productid='"+id+"'"; stmt.executeUpdate(sql); %> <% response.sendRedirect("deletepro.jsp");%> </body> </html> 其中的JAVABEAN是用来连接数据库的,没错的 现在问题是点了表格内容中的删除还是删不掉那一行,请大家帮忙,我是新手,希望大家赐教 |
2.Re:JSP连接数据库出现问题,向大家请教,谢谢! [Re: Bluebluesea] | Copy to clipboard |
Posted by: cxp108 Posted on: 2007-04-13 09:12
你连个参数都不传??? |
3.Re:JSP连接数据库出现问题,向大家请教,谢谢! [Re: Bluebluesea] | Copy to clipboard |
Posted by: Bluebluesea Posted on: 2007-04-13 14:07 传了啊String id=request.getParameter("productid"); 结果就是这个productid就是传不过来啊 |
4.Re:JSP连接数据库出现问题,向大家请教,谢谢! [Re: Bluebluesea] | Copy to clipboard |
Posted by: chengbd Posted on: 2007-04-15 15:51 <td bgcolor="#6633FF" align="center"><span class="STYLE2"><a href="deletepro_do.jsp"> 删除</a></ <a href="deletepro_do.jsp"> 至少也应该是类似<a href="deletepro_do.jsp?id=12345">这样才叫“传递参数” |
5.Re:JSP连接数据库出现问题,向大家请教,谢谢! [Re: Bluebluesea] | Copy to clipboard |
Posted by: zhangsf1982 Posted on: 2007-04-25 13:24 觉得应该把<a href="deletepro_do.jsp"> 改成 <a href="deletepro_do.jsp?Products=<%=rs.getString("productid")%>"> |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |