一个小问题,好心人帮帮我
程序
<%@ page contentType= "test/html;charset=GB2312 " %>
<%@ page import= "java.sql.* "%>
<html>
<body>
<%
Connection con;
Statement sql;
ResultSet rs;
try{Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(
ClassNotFoundException e){}
try{
con=DriverManager.getConnection( "jdbc:odbc:sun ", "sa ", " ");
sql=con.createStatement();
rs=sql.executeQuery( "SELECT * FROM Students ");
while(rs.next()){
out.print(rs.getString(1));
out.print(rs.getString(2));
}
con.close();
}
catch(
SQLException e1){}
%>
</body>
</html>
打开网页后 却跳出来一个文件下载框
打开后里面是数据内容 如下:
<html>
<body>
yuanbaijun 123456789 hahahahha 1254789
</body>
</html>
------解决方案--------------------没启动服务器或者是,页面方法不对吧
------解决方案--------------------response.setContentType( "text/html;charset=GB2312 ");
加这句看看