2012-02-28 78 views
0

我使用JSP文件imagepaths圖片,我想檢索圖像我想檢索存儲在數據庫中的JSP

的問題是,我已經存儲了圖像的路徑,我想從檢索圖像到jsp頁面該圖像路徑

怎麼可能? 我正在使用ms-access數據庫。

Connection con = null; 
    ResultSet rst = null; 
    Statement st = null; 

    try{ 
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
      con=DriverManager.getConnection("jdbc:odbc:register"); 
      st=con.createStatement(); 
      rst = st.executeQuery("select * from productregistration"); 
       while(rst.next()) 
       { 
        %> 
       <img src="<%=rst.getString(1)%>"/> 
        <% 

       } 
       } 
    catch (Exception ex) { 
     ex.printStackTrace(); 
    } 
+0

可能重複【如何檢索和JSP頁面顯示數據庫中的圖像?](http://stackoverflow.com/questions/2340406 /如何從數據庫中檢索和顯示圖像 - jsp頁面) – BalusC 2012-02-28 11:39:52

+0

你想用該代碼做什麼?連接未打開。 'select *'是一件壞事。 'getString(1)'是一件壞事。你必須將圖像路徑添加到'img'標籤。 – vulkanino 2012-02-28 11:41:28

+0

但是當我只寫rst.getString(),所有存儲在數據庫中的圖像路徑被檢索,但是當我把這些值在src中,我什麼也沒有得到 – 2012-02-28 11:46:24

回答

0

雅相關路徑不能被代替獲得使用絕對路徑

相關問題