宝马纯电动汽车i3补贴:关于xml捕获JSP异常的问题!

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 03:44:34
我学的是JSP。程序设计目的如下:计算两个double类型的数据,如果输入正确则在此页面出计算结果。如果输入不对(例如字符'a'),则抛出异常,跳到NumberFormatError.html页面。具体步骤如下:
我在e:\Tomcat 5.5\webapps下建立虚拟目录zhitian在此建立一个文件夹名字为WEB-INF,jisuanqi.jsp和NumberFormatError.html在jisuanqi.jsp中代码为:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.lang.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>COUNT</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF00FF}
.STYLE2 {color: #99FF00}
-->
</style>
</head>

<body>
<hr>
计算结果:
<%
String one_str=request.getParameter("first");
String two_str=request.getParameter("second");
double one_double=Double.parseDouble(one_str);
double two_double=Double.parseDouble(two_str);
out.print(one_double+two_double);
%>
<hr>
<form id="form1" name="form1" method="post" action="jisuanqi.jsp">
<table width="441" border="1">
<tr>
<td colspan="2" bgcolor="#666666">
<marquee direction="left" scrollamount="5">
<span class="STYLE2">输入运算数据</span>
</marquee> </td>
</tr>
<tr>
<td width="120" bgcolor="#CCCCCC"><span class="STYLE1">第一个数</span></td>
<td width="305"><label>
<input type="text" name="first" />
</label></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><span class="STYLE1">运算符号:</span></td>
<td><label>
<select name="operator" id="operator">
<option selected="selected">+</option>
<option>-</option>
<option>*</option>
<option>/</option>
</select>
</label></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><span class="STYLE1">第二个数:</span></td>
<td><label>
<input type="text" name="second" />
</label></td>
</tr>
<tr>
<td colspan="2" bgcolor="#666666"><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
</tr>
</table>
</form>
</body>
</html>

不懂啊