怎么解决?

<%@ 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>

<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>

<td><a href="bookUpdate.jsp?id=<%=rs.getString("Sno") %>"></a><a href="bookSerblet?id=<%=rs.getString("Sno") %>"></a>

</tr>

<%

}

conn.close();

}catch(Exception e){

e.printStackTrace();

}%> </table>



</body>

</html>

报错:

Multiple annotations found at this line:

- Syntax error on tokens, Expression expected 

instead

Syntax error, insert "super ( ) ;" to complete BlockStatements

叶子
浏览 1630回答 1
1回答

慕粉3291149

while循环那里   while循环本来就在<%  %>之中 你在其中使用<%= %>还有你<tr><td>标签应该放在<%%>之外
打开App,查看更多内容
随时随地看视频慕课网APP