java.lang.NumberFormatException: null 错误
org.apache.jasper.JasperException: An exception occurred processing JSP page /ReplyOK.jsp at line 5
2: pageEncoding="UTF-8"%>
3: <%@ page import="java.sql.*" %>
4: <%
5: int id = Integer.parseInt(request.getParameter("id"));
6: int rootId = Integer.parseInt(request.getParameter("rootid"));
7:
8: String title = request.getParameter("title");
我的源代码
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=root";
Connection conn = DriverManager.getConnection(url);
conn.setAutoCommit(false);
String sql = "insert into article values (null, ?, ?, ?, ?, now(), 0)";
PreparedStatement pstmt = conn.prepareStatement(sql);
Statement stmt = conn.createStatement();
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();
------解决方案--------------------根据错误信息提示,应该是request.getParameter("id")返回null了,LZ好好查看一下是不是值能正常取到了
------解决方案--------------------我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.aiyiweb.com/j2se/33144.html