从上一个页面表单接受名字和内容,然后在下面这个页面获得并插入数据库(mysql数据库),然后3秒自动跳转回留言页面. 结果奇怪的是,无法自动跳转,只能手动跳转,手动跳转之后发现留言里出现一大堆null值,数据库里也自动插入一堆null值,而且时间越长,插入的null值越多,试了几次都是这样,好像进入了一个死循环一样,一直在获取数据并插入数据库,第一次获取的是上一个页面传来的值,而接下来获取的都是null 希望高手帮帮忙<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<style type="text/css">
<!--
body {
background-color: #DCF9FA;
}
-->
</style><center>
<h1>我的留言板</h1>

<br>
<hr>
<%
request.setCharacterEncoding("utf-8") ;
String name = request.getParameter("name");
String content = request.getParameter("content");
%>

<%
String DBDRIVER = "com.mysql.jdbc.Driver";
String DBURL = "jdbc:mysql://localhost/notelist?user=root&&password=19870217";
        Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "insert into note values(null,?,?) ";
%>

<%
try {
Class.forName(DBDRIVER);
conn = DriverManager.getConnection(DBURL);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,name);
pstmt.setString(2,content);
pstmt.executeUpdate();
%>
<h3>留言成功!<br/>3秒钟后自动跳转到留言板,如果没有跳转,请点<a href="note.jsp">这里</a></h3>
<%
response.setHeader("refresh","3,URL=note.jsp");

} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(rs != null){
rs.close();
rs = null;
}
if(pstmt != null){
pstmt.close();
pstmt = null;
}
if(conn != null){
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
%>