麻烦帅哥们 大神们 帮帮忙 谢谢

<%@ page language="java" 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>Insert title here</title>

</head>

<body>

<%

try{

String url ="jdbc:sqlserver://localhost:1433;DatabaseName=QiYe";

String username = "sa";

String password = "sa";

Connection conn =null;

Statement statement = null;

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

conn =DriverManager.getConnection(url,username,password);

statement sql = "select * from staff";

ResultSet rs =statement.executeQuery(sql);

%>

<table border="0" cellpadding="4" cellspacing="1" bgcolor="#CBD8AC"

width="100%">

<tr align="center" bgcolor="#FAFA1">

<td>编号</td><td>姓名</td><td>性别</td><td>年龄<td></td>部门</td>

</tr>

<%

while (rs.next()){

%>

<tr align="right">

<td><%=rs.getString("Sno")%></td>

<td><%=rs.getString("Sname")%></td>

<td><%=rs.getString("Ssex")%></td>

<td><%=rs.getString("sage")%></td>

<td><%=rs.getString("sdepeterment")%></td></tr>

<%

}

%>

</table>

conn.close();

}catch(Exception e){

e.printStackTrace();

</body>

</html>

585158b00001ce8e05000181.jpg

585158b200018e1905000462.jpg


叶子
浏览 1253回答 2
2回答

逆光之羽

没有引用对应的类,第一行改成<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.sql.*"     pageEncoding="UTF-8"%>statement sql 改成String sql<%conn.close(); }catch(Exception e){ e.printStackTrace(); } %> //这一句加上<%%>标签

叶子

帮看看  这是什么情况啊?
打开App,查看更多内容
随时随地看视频慕课网APP