【发布时间】:2013-11-09 06:43:43
【问题描述】:
下面是我的 JdbsJsp.java 代码
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" errorPage="/ErrorPage.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/saumil","root","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
{
out.println(rs.getInt(1)+" "+rs.getString(2));
}
}
catch(Exception e)
{
}
%>
</body>
</html>
而我的错误页面如下,
<%@page isErrorPage="true"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>An Exception has occured(probably SQLException)</h1>
<%=exception.getMessage()%>
</body>
</html>
我特意将表名设置为'emp'(数据库中没有这样的表)来显示错误页面。但是,我没有显示错误页面,而是得到了一个完全空白的屏幕。没有显示“发生异常(可能是 SQLException)”的消息。 希望有人能指导我。
【问题讨论】:
标签: java jsp google-chrome exception