调试JSP时弹出迅雷,么回事?
今天,我安照孙卫琴的Tomcat与JAVA web开发一书中的程序DbJsp.jsp,把文件代码自己敲了一遍,然后运行。迅雷居然弹出来,并且提示我是否要下载。
程序代码如下:
<%@ page import= "java.io.* "%>
<%@ page import= "java.util.* "%>
<%@ page import= "java.sql.* "%>
<%@ page contentType= "text/html:charset=GB2312 " %>
<html>
<head>
<title> DbJsp.jsp </title>
</head>
<body>
<%
try
{
Connection con;
Statement stmt;
ResultSet rs;
Class.forName( "com.mysql.jdbc.Driver ");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
String dbUrl= "jdbc:mysql://localhost:3306/BookDB?useUnicode=true&characterEncoding=GB2312 ";
String dbUser= "dbuser ";
String dbPwd= "1234 ";
con=java.sql.DriverManager.getConnection(dbUrl,dbUser,dbPwd);
stmt=con.createStatement();
stmt.executeUpdate( "INSERT INTO books(id,name,title,price)VALUES( '999 ', 'Tom ', 'TomcatBible ',44.5) ");
rs=stmt.executeQuery( "SELECT id,name,title,price from books ");
out.println( " <table border=1 width=400> ");
while(rs.next())
{
String col1=rs.getString(1);
String col2=rs.getString(2);
String col3=rs.getString(3);
float col4=rs.getFloat(4);
out.println( " <tr> <td> "+col1+ " </td> <td> "+col2+ " </td> <td> "+col3+ " </td> <td> "+col4+ " </td> </tr> ");
}
out.println( " </table> ");
stmt.executeUpdate( "DELETE FROM books WHERE id= '999 ' ");
rs.close();
stmt.close();
con.close();
}
catch (Exception e){out.println(e.getMessage());}
%>
</body>
</html>
请知道原因的高手指点我一下,在此谢谢了!
------解决方案-------------------- <%@ page contentType= "text/html:charset=GB2312 " %>
<%@ page contentType= "text/html;charset=GB2312 " %>
冒号改分号就OK了!!
------解决方案--------------------这段 <%@ page contentType= "text/html:charset=GB2312 " %> 里的 你写成冒号了。