日期:2014-05-16 浏览次数:20541 次
<!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>Compute</title> </head> <body bgcolor="#FFFFFF"> <div align="center"> <form method="post" action="Divide.jsp"> <p>--- 整数除法 ---<p> 被除数<input type="text" name="value1"> 除数<input type="text" name="value2"> </p> <p> <input type="submit" name="Submit" value="计算"> </p> </form> </div> </body> </html>
<%@ page language="java" errorPage="error.jsp" contentType="text/html; charset=UTF-8" 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>Divide</title> </head> <body bgcolor="#FFFFFF"> <center> <br> <h1> <% int dividend = 0; int divisor = 0; int result = 0; try { dividend = Integer.parseInt(request.getParameter("value1")); } catch (NumberFormatException nfex) { throw new NumberFormatException("被除数不是整数! "); } try { divisor = Integer.parseInt(request.getParameter("value2")); } catch (NumberFormatException nfex) { throw new NumberFormatException("除数不是整数! "); } result = dividend / divisor; out.println(dividend + " / " + divisor + " = " + result); %> </h1> <br> <br> <br> <a href="javascript: history.back();">返回</a> </center> </body> </html>
<%@ page language="java" isErrorPage="true" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!-- isErrorPage的作用设置当前页面为错误页面,当在别的页面设置errorPage="error.jsp" 后,在设置页面出现问题后就自动会跳转到当前的错误页面 --> <!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>Compute error</title> </head> <body bgcolor="#FFFFFF"> <div align="center"> <br> <br> <h1> 错误信息 </h1> <hr> <p> <h3><%=exception.toString()%></h3> <br> <br> <br> <a href="javascript: history.back();">返回</a> </div> </body> </html>