我正在尝试从表客户端中选择数据,并使用HTML表格形式的servlet显示它。 我面临的问题是在表格的显示中,每行中的单元格与下一行宽度的单元格不匹配,如何解决这个问题?
问题解决了
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection cnx=DriverManager.getConnection("jdbc:derby://localhost:1527/ndb","me","123");
Statement st=cnx.createStatement();
ResultSet rs=st.executeQuery("Select * from Clients");
out.println("<HTML>");
// Start on the body
out.println("<BODY>");
out.println("<CENTER>");
out.println("<table BORDER=1 CELLPADDING=0 CELLSPACING=0 WIDTH=50% >");
while (rs.next()){
out.println("<tr>");
out.print("<td>"+rs.getString("CIN")+ "</td>");
out.print("<td>"+rs.getString("NOM")+ "</td>");
out.print("<td>"+rs.getString("PRENOM")+ "</td>");
out.print("<td>"+rs.getString("TEL")+ "</td>");
out.print("<td>"+rs.getString("EMAIL")+ "</td>");
out.print("<td>"+rs.getString("SEX")+ "</td>");
out.println("</tr>");
}
} catch(Exception ex){
}
out.println("</table>");
out.println("</CENTER>");
out.println("</BODY></HTML>");
}