首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

java.lang.NumberFormatException: null 异常

2013-09-11 
java.lang.NumberFormatException: null 错误org.apache.jasper.JasperException: An exception occurred

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好好查看一下是不是值能正常取到了
[解决办法]

探讨

根据错误信息提示,应该是request.getParameter("id")返回null了,LZ好好查看一下是不是值能正常取到了

我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html

热点排行