日期:2014-05-17  浏览次数:20899 次

求教!Integer.parseInt()将从页面获取的数据转型时老出错
这是报错
org.apache.jasper.JasperException: An exception occurred processing JSP page /register_deal.jsp at line 42

39: Integer price=Integer.parseInt("10"); 
40: String address=request.getParameter("address");
41: String telephone2=request.getParameter("telephone");
42: Integer telephone=Integer.parseInt(telephone2);
43: String email=request.getParameter("email");
44: String certification=request.getParameter("certification");
45: String certification2=request.getParameter("certification2");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


这是我的源代码(初学,代码不规范,见谅!)
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'register_deal.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
  
  <body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url= "jdbc:mysql://localhost:3306/graduationproject?user=root&password=123&useUnicode=true&characterEncoding=GB2312";
Connection connection=DriverManager.getConnection(url); 
Statement statement = connection.createStatement();
request.setCharacterEncoding("gb2312");
String ICP=request.getParameter("ICP");
String name=request.getParameter("name");
String brief=request.getParameter("brief");
String material=request.getParameter("material");
String price2=request.getParameter("price");
Integer price=Integer.parseInt("10"); 
String address=request.getParameter("address");
String telephone2=request.getParameter("telephone");
Integer telephone=Integer.parseInt(telephone2);
String email=request.getParameter("email");
String certification=request.getParameter("certification");
String certification2=request.getParameter("certification2");
String sql="insert into supplier values