当前位置: 代码迷 >> Java Web开发 >> 数据库数据输出替空白
  详细解决方案

数据库数据输出替空白

热度:103   发布时间:2016-04-17 13:53:53.0
数据库数据输出为空白
代码是这样的:
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 无标题文档 </title>
</head>

<body>
<%
final   String   DBDRIVER   =   "com.microsoft.jdbc.sqlserver.SQLServerDriver "   ;  
final   String   DBURL   =   "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=myjob ";
response.setCharacterEncoding( "GBK ");
Connection   conn   =   null   ;  
ResultSet   rs   =   null   ;  
String   name=null;
String   password=null;
String   user= "sa ";
String   pass= " ";
//String   name1=new   String(request.getParameter( "name ").getBytes( "ISO8859_1 ")).trim();
Statement   st=null;
PreparedStatement   stat=null;
boolean   flag=true;
Class.forName(DBDRIVER)   ;  
conn   =   DriverManager.getConnection(DBURL,user,pass)   ;  
st=conn.createStatement();
rs   =   st.executeQuery( "select   email   from   user1   where   name= '11 ' "   )   ;  
rs.close();                
conn.close();  
%>
<table   width= "100% "   height= "400 "   border= "1 ">
    <tr>
        <td> <jsp:include   page= "update.jsp "   flush= "true "> </jsp:include> </td>
        <td> <table   width= "100% "   height= "81% "   border= "1 ">
            <tr>
                <td> &nbsp; </td>
            </tr>
            <tr>
                <td> <table   width= "200 "   border= "1 ">
                    <tr>
                        <td> 用户名 </td>
                        <td> <%=rs.getString( "email ")%> </td>
                    </tr>
                    <tr>
                        <td> 联系电话 </td>
                        <td> &nbsp; </td>
                    </tr>
                    <tr>
                        <td> E-MAIL </td>
                        <td> &nbsp; </td>
  相关解决方案