jsp修改删除指定数据 我想做一个从数据库读出数据,右边同时有一个修改和删除按钮。如何能够让我点击相应行的按钮时,能对数据库中相应的数据进行修改。修改和删除的sql我都会,就是这个按钮与指定行的数据的对应,和也面的跳转不会,能给出代码吗。谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 删除肯定要跳第二个页面,修改是用JavaScript.让本来不能修改的,变成能修改的。修改我还没有作出来,给你删除的页面吧third.jsp如下<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%><jsp:useBean id="user" class="com.zb.userweb.sxj.services.ShowUserinfosService" scope="page" /><% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'reg.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <link rel="stylesheet" type="text/css" href="css/third.css"> <script type="text/javascript" src="js/jquery.js" ></script> <script type="text/javascript" src="js/reg.js"></script> </head> <body> <body> <c:set var="lst" value="<%=user.findAll()%>" scope="page"></c:set> <form> <Table border="1" cellpadding="0" cellspacing="0"> <Tr> <td class="btnav" onmouseover="style.backgroundColor='#84DFC1';" onmouseout="style.backgroundColor='#84C1DF'"> 用户编号 </Td> <td class="btnav" onmouseover="style.backgroundColor='#84DFC1';" onmouseout="style.backgroundColor='#84C1DF'"> 用户名 </Td> <td class="btnav" onmouseover="style.backgroundColor='#84DFC1';" onmouseout="style.backgroundColor='#84C1DF'"> 修改 </Td> <td class="btnav" onmouseover="style.backgroundColor='#84DFC1';" onmouseout="style.backgroundColor='#84C1DF'"> 删除 </Td> </Tr> <c:forEach var="users" items="${lst}"> <Tr> <td> ${users.id } </Td> <td> <input type="text" name="${users.username }" id="${users.username }" disabled="disabled" value="${users.username }" /> </Td> <td> <input type="button" name="update" id="update" value="修改" /> </Td> <td> <a href="fourth.jsp?userid=${users.id}">删除</a> </Td> </Tr> </c:forEach> </Table> </form> </body></html> fourth.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@page import="com.zb.userweb.sxj.entity.Userinfos"%><%@page import="com.zb.userweb.sxj.services.DeleteUserService"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'fourth.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% int id=Integer.parseInt( request.getParameter("userid")); Userinfos user=new Userinfos(); user.setId(id); DeleteUserService du=new DeleteUserService(); if(du.deleteUser(user)>0) { response.sendRedirect("third.jsp"); } else { response.sendRedirect("fourth.jsp"); } %> </body></html> 服务类DeleteUserService package com.zb.userweb.sxj.services;import java.util.List;import com.zb.userweb.sxj.entity.Userinfos;import com.zb.userweb.sxj.factory.ImplFactory;import com.zb.userweb.sxj.idao.IBaseDAO;import com.zb.userweb.sxj.impl.UserinfosImpl;public class DeleteUserService {private UserinfosImpl uImpl; public DeleteUserService(){ IBaseDAO<Userinfos> ibase=ImplFactory.findDaoByName("UserinfosImpl"); uImpl=(UserinfosImpl) ibase; } public int deleteUser(Userinfos user){ return uImpl.delete(user.getId()); }} jstl标签问题 删除不了cookie!!头疼..急啊.. window.open 打开窗口 处于 最上层? 急,大家帮忙看看在FirFox下要点两下才能弹出层 JS 浏览器兼容问题 window.open()的疑问! 一个小问题 求几个jScript方法,给分! nowrap如何使用? 在netscape6.1中,如何取得Div数组? 我用页面中td的id无法接收ajax的值 通过js调用dll实现文件操作
修改我还没有作出来,给你删除的页面吧
third.jsp
如下
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="user"
class="com.zb.userweb.sxj.services.ShowUserinfosService" scope="page" />
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'reg.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page"> <link rel="stylesheet" type="text/css" href="css/third.css">
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="js/reg.js"></script>
</head> <body>
<body>
<c:set var="lst" value="<%=user.findAll()%>" scope="page"></c:set>
<form>
<Table border="1" cellpadding="0" cellspacing="0">
<Tr>
<td class="btnav" onmouseover="style.backgroundColor='#84DFC1';"
onmouseout="style.backgroundColor='#84C1DF'">
用户编号
</Td>
<td class="btnav" onmouseover="style.backgroundColor='#84DFC1';"
onmouseout="style.backgroundColor='#84C1DF'">
用户名
</Td>
<td class="btnav" onmouseover="style.backgroundColor='#84DFC1';"
onmouseout="style.backgroundColor='#84C1DF'">
修改
</Td>
<td class="btnav" onmouseover="style.backgroundColor='#84DFC1';"
onmouseout="style.backgroundColor='#84C1DF'">
删除
</Td>
</Tr>
<c:forEach var="users" items="${lst}">
<Tr>
<td>
${users.id }
</Td>
<td>
<input type="text" name="${users.username }"
id="${users.username }" disabled="disabled"
value="${users.username }" />
</Td>
<td>
<input type="button" name="update" id="update" value="修改" />
</Td>
<td>
<a href="fourth.jsp?userid=${users.id}">删除</a>
</Td>
</Tr>
</c:forEach>
</Table>
</form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.zb.userweb.sxj.entity.Userinfos"%>
<%@page import="com.zb.userweb.sxj.services.DeleteUserService"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'fourth.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<%
int id=Integer.parseInt( request.getParameter("userid"));
Userinfos user=new Userinfos();
user.setId(id);
DeleteUserService du=new DeleteUserService();
if(du.deleteUser(user)>0)
{
response.sendRedirect("third.jsp");
}
else
{
response.sendRedirect("fourth.jsp");
}
%>
</body>
</html>
package com.zb.userweb.sxj.services;import java.util.List;import com.zb.userweb.sxj.entity.Userinfos;
import com.zb.userweb.sxj.factory.ImplFactory;
import com.zb.userweb.sxj.idao.IBaseDAO;
import com.zb.userweb.sxj.impl.UserinfosImpl;public class DeleteUserService {
private UserinfosImpl uImpl;
public DeleteUserService(){
IBaseDAO<Userinfos> ibase=ImplFactory.findDaoByName("UserinfosImpl");
uImpl=(UserinfosImpl) ibase;
}
public int deleteUser(Userinfos user){
return uImpl.delete(user.getId());
}
}