简单BBS jsp提交回复页面报这个异常,没分了求好心人帮下
这是我jsp页面回复提交的代码:<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<%@ page import="java.sql.*" %>
<%
int id=Integer.parseInt(request.getParameter("id"));
int rootid= Integer.parseInt(request.getParameter("rootid"));
String title= request.getParameter("title");
String cont = request.getParameter("cont");
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/bbs?user=root&password=admin";
Connection conn = DriverManager.getConnection(url);
String sql= "insert into article values (null,?,?,?,?,now(),0)";
PreparedStatement pstmt= conn.prepareStatement(sql);
Statement stmt = conn.createStatement();
conn.setAutoCommit(false);
pstmt.setInt(1,id);
pstmt.setInt(2,rootid);
pstmt.setString(3,title);
pstmt.setString(4,cont);
pstmt.executeUpdate();
stmt.executeUpdate("update article set isleaf = 1 where id="+id);
conn.commit();
conn.setAutoCommit(true);
stmt.close();
pstmt.close();
conn.close();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>Insert title here</title>
</head>
<body>
<font>
k
</font>
</body>
</html>
异常是:严重: Servlet.service() for servlet jsp threw exception
java.lang.NumberFormatException: For input string: "id"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)