今日学习内容
<%@ page import="java.sql.*" %><%@ page import="java.sql.DriverManager" %><%--
Created by IntelliJ IDEA.
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<form action="modify_teacher_course_end_end.jsp">
<%
int tid=Integer.parseInt(request.getParameter("tid"));
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
request.setCharacterEncoding("utf-8");
Connection conn = null;
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/2017xuanke", "root", "123456");
Statement stat = null;
stat = conn.createStatement();
String sql = "SELECT * FROM course where tid="+tid ;
ResultSet rs = stat.executeQuery(sql);
while (rs.next()) {
int column1 = rs.getInt("cid");
session.setAttribute("cid",column1);
String column2 =rs.getString("name");
String column3 = rs.getString("time");
String column4 = rs.getString("cishu");
String column5 = rs.getString("college");
String column6 = rs.getString("tid");
String column7 = rs.getString("t_name");
String column8 = rs.getString("renshu");
// 其他处理...
// 在页面上显示数据
%>
<p>课程编号: <%= column1 %></p>
<br>
<p>课程名称: <%= column2 %></p>
<br>
<p>开课时间: <%= column3 %></p>
<br>
<p>节次: <%= column4 %></p>
<br>
<p>学院: <%= column5 %></p>
<br>
<p>教师id: <%= column6 %></p>
<br>
<p>教师姓名: <%= column7 %></p>
<br>
<p>限制人数: <%= column8 %></p>
<br>
<p>修改为:</p><input type="text" name="renshu" id="renshu">
<br>
<input type="submit" value="修改">
</form>
<br>
<br><br><br>
<hr>
<%
}
%>
</body>
</html> 标签:stat,String,getString,rs,11.21,tid,conn From: https://www.cnblogs.com/zjm921/p/17908599.html