首页 > 代码库 > jsp怎么从数据库取数据并显示再表格上
jsp怎么从数据库取数据并显示再表格上
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<table border="1" width="100%" >
<tr>
<td width="60" valign="top" bgcolor="#999999" class="dh"><div align="center">name</div></td>
<td width="240" valign="top"><div align="left">password<br>
</div></td>
<td width="9" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<%
request.setCharacterEncoding("gb2312");
java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/GPSDatabase","root","123456");
String sql1="SELECT*from User_Table";
Statement statemenet = (Statement) conn.createStatement();
ResultSet rs1 = statemenet.executeQuery(sql1);
while(rs1.next()){
%>
<tr>
<td width="60" valign="top" bgcolor="#999999" class="dh"><div align="center"><span class="style8"><%=rs1.getString("Email")%>" </span></div></td>
<td width="240" valign="top"><div align="left"><span class="style8"><%=rs1.getString("Password")%></span><br>
</div></td>
<td width="9" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<%
} rs1.close();
%>
</table>
jsp怎么从数据库取数据并显示再表格上