2016-12-11 147 views
-2

我不能運行這個程序,但是當我把HTML作爲打印的< %%>,我可以運行。我不知道爲什麼 <%@ page的contentType = 「text/html的;字符集= UTF-8」 %> <%@頁面進口= 「java.sql中*」 %>我不能運行這個jsp。我不知道爲什麼

<% 
     Connection con; 
     Statement sql; 
     ResultSet rs; 
     Class.forName("com.mysql.jdbc.Driver").newInstance(); 

      String uri="jdbc:mysql://localhost:3306/Yk"; 
      con=DriverManager.getConnection(uri,"root",""); 
      sql=con.createStatement(); 
      rs=sql.executeQuery("SELECT * FROM Article"); 


    %> 
    <html> 
    <body> 

    <% while(rs.next()){ 
     String paperid = rs.getString("id"); 
     String papertitle =rs.getString("title"); 
     String name = rs.getString("name"); 
    %> 


    <table> 
     <tr> 
      <td width="100">編號</td> 
      <td width="100">主題</td> 
      <td width="50">內容</td> 

     </tr> 
     <tr> 
      <td width = "100"><%=paperid%></td> 
      <td width = "100"><%=papertitle%> 
      </td> 
      <td width="50"><%=name%></td> 

     </tr> 
    </table> 
    </body> 
    </html> 

我不能運行這個程序,但是當我把HTML in < %%> as print,i can run .i不知道爲什麼

回答

1

我想你應該把兩個< %%>合併成一個< %%>並且不要在其中放入HTML。 希望這會幫助你

+0

我解決了它,我錯過了<%}%>在結束,hhhhh –

+0

是的,你是對的。 – Romeo

相關問題