jsp如何把数据库里的内容读取到文本框里再修改呢??
例如一个学生信息管理系统,我想把某一学生的所有信息读取到多个文本框里,在有选择的进行修改???...
例如一个学生信息管理系统,我想把某一学生的所有信息读取到多个文本框里,在有选择的进行修改???
展开
1个回答
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<%@ page
language="java"
import="java.sql.*"
contentType="text/html; charset=GBK"
pageEncoding="GBK"
%>
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<TITLE>dbtest.jsp</TITLE>
</HEAD>
<BODY>
<P> 员工列表</P>
<table border=1>
<%String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liveflow";
String user ="sa";//数据库用户名
String password = "sa";//数据库用户密码
String sqlStr = "select * from employee_base";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection( url, user, password );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( sqlStr );
while(rs.next())
{%>
<tr><td><%=rs.getString("employee_id")%></td><td><input value="<%=rs.getString("employee_name")%>“></td><td><input value="<%=rs.getString("post_name")%>"></td><td><input value="<%=rs.getString("rela_phone")%></td><td><%=rs.getString(6)%>"></td></tr>
<% }%>
<%
rs.close();
st.close();
con.close();
%>
</table>
</BODY>
</HTML>
<HTML>
<HEAD>
<%@ page
language="java"
import="java.sql.*"
contentType="text/html; charset=GBK"
pageEncoding="GBK"
%>
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<TITLE>dbtest.jsp</TITLE>
</HEAD>
<BODY>
<P> 员工列表</P>
<table border=1>
<%String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liveflow";
String user ="sa";//数据库用户名
String password = "sa";//数据库用户密码
String sqlStr = "select * from employee_base";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection( url, user, password );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( sqlStr );
while(rs.next())
{%>
<tr><td><%=rs.getString("employee_id")%></td><td><input value="<%=rs.getString("employee_name")%>“></td><td><input value="<%=rs.getString("post_name")%>"></td><td><input value="<%=rs.getString("rela_phone")%></td><td><%=rs.getString(6)%>"></td></tr>
<% }%>
<%
rs.close();
st.close();
con.close();
%>
</table>
</BODY>
</HTML>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询