我开发了一个简单的 jsp 页面,其中包含两个文本字段和一个用于添加两个数字的提交按钮。在浏览器中编译后显示错误:
HTTP Status 500
org.apache.jasper.JasperException: java.lang.NumberFormatException: null
这里的代码:
<%--
Document : index
Created on : Mar 5, 2013, 7:21:57 PM
Author : VIJI
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form>
<input type="text" name="a"></input>
<input type="text" name="b"></input>
<input type="submit" value="ADD"></input>
<%!
int a,b,c;
%>
<%
a=Integer.parseInt(request.getParameter("a"));
b=Integer.parseInt(request.getParameter("b"));
c=a+b;
%>
Addition of two numbers is<%=c%>
</form>
</body>