2015-10-19 25 views
0

我在JSP中創建了一個表格,其中我使用硬代碼顯示了一些值。 我想使用腳本和模型顯示這些值。有人幫我如何做到這一點?從數據庫如何使用模型和腳本獲取值

<tr> 
      <td>Automobile</td> 
      <td>11-JUN-2015</td> 
      <td>10-FEB-2016</td> 
      <td>Cars and bikes</td> 

      </tr> 

回答

0

獲取值:

<%rst=stmt.executeQuery("select * from auto_details");%> 

樣本HTML表:

<html> 
      <body> 
      <center> 
       <h2>AutoList</h2> 
       <table border="1" cellspacing="0" cellpadding ="0"> 
       <tr> 
        <td><b>S.No</b></td> 
        <td><b>Date</b></td> 
        <td><b>typeofvichele</.b></td> 
       </tr> 
        <% 
        int no=1; 
        while(rst.next()){ 
        %> 
        <tr> 
         <td><%=no%></td> 
         <td><%=rst.getString("date")%></td> 
         <td> <%=rst.getString("typeofvichele")%> </td> 
        </tr> 
        <% 
        no++; 
     } 
     rst.close(); 
     stmt.close(); 
     con.close(); 
    %> 
       </table> 
       </center> 
      </body> 
     </html> 
相關問題