JSP,如何将SQL数据库表中的数据显示出来?
<%@pagecontentType="text/html;charset=gb2312"import="java.sql.*"%><jsp:useBeanid="con...
<%@ page contentType="text/html; charset=gb2312" import="java.sql.*"%> <jsp:useBean id="conndata" scope="page" class="jiaoyou.sqlbean"/> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title> 个人详细信息 </title> </head> <%! ResultSet rs=null; String sql; String ID,userid; String login; int num; %> <body bgcolor="#ffffff"> <% ID=request.getParameter("ID"); sql="select * from tb_member where ID="+ID+""; login=(String)session.getAttribute("login"); userid=(String)session.getAttribute("userid"); if(login==null) { %> <script language="javascript"> alert("您还未登录,不能浏览详细信息!!!"); <% response.sendRedirect("index.jsp"); %> </script> <%} %> <table width="785" height="247" border="1" align="center" cellpadding="0" cellspacing="0"bordercolor="#FFFFFF" bordercolordark="#333333" bordercolorlight="#FFFFFF"> <tr> <td width="100%" height="52" colspan="4"> <p align="center"><font face="隶书" size="7">用户个人详细信息</font></td> </tr> <%try { rs=conndata.execQuery(sql); if(rs.next()) { %> <tr> <td width="100%" height="29" align="center">用户名:</td> <td width="83%" height="29" align="center"><%=rs.getString("userid")%></td> <td width="17%" height="29" align="center" valign="middle">密码:</td> <td width="30%" height="29" align="center"><%=rs.getString("password")%></td> </tr> <tr> <td width="100%" height="29" align="center">性别:</td> <td width="83%" height="29" align="center"><%=rs.getString("sex")%> </td> <td width="17%" height="29" align="center" valign="middle">年龄:</td> <td width="30%" height="29" align="center"> <%=rs.getString("birth")%></td> </tr> <tr> <td width="100%" height="29" align="center">联系电话:</td> <td width="83%" height="29" align="center"><%=rs.getString("phone")%></td> <td width="17%" height="29" align="center" valign="middle">邮箱地址:</td> <td width="30%" height="29" align="center"><%=rs.getString("email")%></td> </tr> <tr> <td width="100%" height="29" align="center">密码提示:</td> <td width="83%" height="29" align="center"><%=rs.getString("tishi")%></td> <td width="17%" height="29" align="center" valign="middle">提示答案:</td> <td width="30%" height="29" align="center"><%=rs.getString("answer")%></td> </tr> <tr> <td width="100%" height="31" align="center">联系地址:</td> <td width="83%" height="31" align="left" colspan="3"><%=rs.getString("address")%></td> </tr> <tr> <td width="100%" height="1" align="center">备注信息:</td> <td width="83%" height="1" align="center" colspan="3"> <p align="left"> <textarea rows="3" name="S1" cols="76"><%=rs.getString("memo")%></textarea> </td> </tr> <% if(userid.equals(userid)) { %> <tr> <td width="100%" height="45" colspan="4" align="center"> <a href="informationmodify.jsp?ID=<%=ID%>">修改</a> <a href="information_delete.jsp?ID=<%=ID%>">删除</a></td> </tr> <% } }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询