【发布时间】:2014-08-04 08:57:43
【问题描述】:
环境:我在 eclipse kepler 中工作,我的 MySQL 数据库在 AWS RDS 上。我的目标是创建一个基于 Web 的项目,因此我的项目是“AWS Java Web 项目”。同样对于数据库连接,我已经将 mysql-connector-*-bin.jar 文件添加到我的构建路径中。
下面的代码当我作为一个简单的 java 应用程序运行时,它运行良好,但是当我在 Tomcat 服务器上运行它时,它显示以下错误:
org.apache.jasper.JasperException: 在第 114 行处理 JSP 页面 /WelcomeCustomer.jsp 时发生异常
第 114 行:
String s_id_string=(String)request.getParameter("s_id");
int s_id = Integer.parseInt(s_id_string);
根本原因
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
org.apache.jsp.WelcomeCustomer_jsp._jspService(WelcomeCustomer_jsp.java:180)
第 180 行:
o_insert.setString(4, Cust_contact_string);
注意:Cust_contact_string 是字符串类型。
请帮助我,我似乎无法解决这个错误!
提前致谢
更新:
<form name="s_id_form" method="post" onsubmit=" return s_id_form()">
Choose a Shop from above by entering the respective s_id :
<input type="text" name="s_id" id="s_id"> <input type="submit" value="submit">
</form>
<%
String s_id_string=(String)request.getParameter("s_id");
int s_id = Integer.parseInt(s_id_string);
%>
【问题讨论】:
-
更多参考我粘贴整个代码:
-
您不能将 null 解析为数字。所以在转换(解析)之前确定是否为null。
-
是的,我正在通过如下的 javascript 代码检查它是否为空:function s_id_form() { var s_id = document.s_id_form.s_id; if(s_id.value == "") { window.alert("请输入店铺ID!");返回假; } 返回真; }
-
不要将代码作为评论发布,而是用它们更新您的帖子。
标签: java mysql eclipse jsp amazon-rds