老问题:当我点击del.jsp时,页面不更新,即没有调用,只有再点一次,或手动刷新一次才删除记录.神啊救救我啊!

ff00 2002-04-05 04:05:27
list.jsp 显示留言页面
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>留言列表</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
//response.setDateHeader("Expires", 0);
String DBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String DBLocation="jdbc:odbc:lyb";
String DBUser="";
String DBPwd="";
Class.forName(DBDriver);
Connection conn=DriverManager.getConnection(DBLocation,DBUser,DBPwd);
Statement stmt=conn.createStatement();
String sqlstr;
sqlstr="select * from lyb";
ResultSet rs=stmt.executeQuery(sqlstr);
conn.commit();
%>
<body bgcolor="#E8E8E8" topmargin="4" leftmargin="2">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="773">
<tr>
<td>
<p align="center"><img border="0" src="img/dev.jpg" width="153" height="60"></td>
<td><img border="0" src="img/BannerPic_19.gif" width="468" height="60"></td>
</tr>

<tr>
<td colspan="2"></td>
</tr>
</table>

<table border="0" cellspacing="0" width="773" cellpadding="0">
<tr><td colspan="2" width="174"></td><td width="341"></td><td width="235" colspan="2">
</td></tr> <tr>
<td width="763" align="center" colspan="5">
<hr>
</td>
</tr>
<%
while(rs.next()){
String id=rs.getString("id");
String title=rs.getString("title");
String company=rs.getString("company");
String contactman=rs.getString("contactman");
String tel=rs.getString("tel");
String email=rs.getString("email");
String datetime=rs.getString("datetime");
String faces=rs.getString("faces");
String content=rs.getString("content");%>
<tr>
<td width=56 align=center></td>
<td width=112>
<p class=text> 单位名称:</p>
</td>
<td width=509 colspan=2>
<p class=text><%=company%></td>
<td width=61>管理:<a href=del.jsp?id=<%=id%>>删除</a></td>
</tr>
<tr>
<td width=56 align=center></td>
<td width=112>
<p class=text> 联 系 人:</p>
</td>
<td width=509 colspan=2>
<p class=text><%=contactman%></td>
<td width=61></td>
</tr>
<tr>
<td width=56 align=center></td><td width=112>
<p class=text> 联系电话:</p>
</td>
<td width=509 colspan=2>
<p class=text><%=tel%></td>
<td width=61></td>
</tr>
<tr>
<td width=56 align=center></td>
<td width=112>
<p class=text> 电子邮件:</p>
</td>
<td width=509 colspan=2>
<p class=text><a href=mailto:<%=email%>><%=email%></a></td>
<td width=61></td>
</tr>
<tr>
<td width=56 align=center></td>
<td width=112>
<p class=text> 留言时间:</p>
</td>
<td width=509 colspan=2>
<p class=text><%=datetime%><img border=0 src=<%=faces%>></td>
<td width=61></td>
</tr>
<tr>
<td width=56></td>
<td width=101>
<p class=text> 留言主题:</p>
</td>
<td width=424 colspan=2><%=title%>
</td>
<td width=61></td>
</tr>
<tr>
<td width=56></td>
<td width=103>
<p class=text> 留言内容:</p>
</td>
<td width=419 colspan=2><%=content%></td>
<td width=61></td></tr><tr><td width=756 colspan=5>
<hr>
</td>
</tr>
<%}
%> </table>
</center>
</body>
</html>
====================
del.jsp(删除页面)
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.sql.*"%>
<%
String DBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String DBLocation="jdbc:odbc:lyb";
String DBUser="";
String DBPwd="";
Class.forName(DBDriver);
Connection conn=DriverManager.getConnection(DBLocation,DBUser,DBPwd);
Statement stmt=conn.createStatement();
String id=request.getParameter("id");
String sql;
sql="delete from lyb where id="+id;
stmt.executeUpdate(sql);
response.sendRedirect("list.jsp");
%>
...全文
13 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
可乐加水 2002-04-06
farword过去看看!
回复
BrentIvan 2002-04-05
跳转时这样写:
<a href="list.jsp?now=<%= new Date(); %>">list.jsp</a>

response.sendRedirect("list.jsp?now=" + new Date());
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告