<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.sql.*"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>实现查询页面</title>
</head>
<body>
<center>
<% String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//加载JDBC驱动
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=online course";
//连接服务器和数据库
String userName = "ninet"; // 默认用户名
String userPwd = "123"; // 密码
Connection dbConn = null;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
// System.out.println("Connection Successful!");
// 如果连接成功 控制台输出Connection Successful!
} catch (Exception e) {
e.printStackTrace();
// System.out.println("连接失败");
}
request.setCharacterEncoding("UTF-8");//设置字符编码,避免出现乱码
String sname=request.getParameter("sname");
String sql="select * from student where sname like '%'+?+'%'";
PreparedStatement pstmt=dbConn.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
pstmt.setString(1, sname);
ResultSet rs=pstmt.executeQuery();
rs.last();
%>你要查询的学生数据表中共有
<font size="5" color="red"><%=rs.getRow()%></font>人
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<table id="t1" border="2" bgcolor="ccceee" width="650">
<tr bgcolor="CCCCCC" align="center">
<td>记录条数</td>
<td>学号</td>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>系号</td>
<td>密码</td>
</tr>
<% rs.beforeFirst(); //移至第一条记录之前
while (rs.next()){
%> <tr align="center">
<td><%=rs.getRow() %></td>
<td id="td1"><%=rs.getString("sno") %></td>
<td><%=rs.getString("sname") %></td>
<td><%=rs.getString("ssex") %></td>
<td><%=rs.getString("sbirth") %></td>
<td><%=rs.getString("mno") %></td>
<td><%=rs.getString("spword") %></td>
<td><input type="button" value="更新" onclick="a()"/></td>
<script>
function a(){
<%
String sno=rs.getString("sno");
session.setAttribute("sno", sno);
%>
window.location.href="11.jsp";
}
</script>
</tr>
<%} %>
</table>
</center>
<%if(rs!=null){rs.close();}
if(pstmt!=null){pstmt.close();}
if(dbConn!=null){dbConn.close();}
%>
</body>
</html>
这段代码只能够获取表中最后一行的数据,怎么才能够获得鼠标所点击的行的相关数据呀?这段方法当中应该加什么代码