2016-06-08 62 views
0

這是我的第一篇文章,我想特別感謝這個偉大網站的創始人。無法顯示來自tomcat 8 webapps的所有圖像

我的問題似乎是現有的重複。不過,我想指出,事實並非如此。幾周以來,我通過網絡進行了大量的搜索,發現了我可以幫助的這個迴應。但嘗試後,我沒有找到解決辦法。

Simplest way to serve static data from outside the application server in a Java web application

這裏是我的問題:

  1. 我使用Tomcat 8和我的圖片保存在C:\服務器\ Tomcat的\的webapps \ uploadimg \ PA \ imgstsore

  2. 每個圖像的名稱存儲在數據庫中。

  3. 下面的jsp代碼是假設顯示我的所有圖像。不幸的是只有我的標誌圖像顯示。在解決方案請

<%@標籤庫前綴= 「C」 URI = 「http://java.sun.com/jsp/jstl/core」 %>

 <!--Logo --> 
     <c:if test="${p.imgLargeur == 220}"> 
     <table> 
      <tr>     
       <td><img width="220" height="200" **src="http://localhost:8080/uploadimg/pa/imgstore/${p.imgApropos}">**      </td>     
       <td style="font-size: 14pt;text-align: center;width:710px" >Logo ${p.apropos}</td>     
      </tr> 
     </table><br> 
     </c:if> 

     <!--image with text by the side --> 
     <c:if test="${p.imgLargeur == 200}"> 
     <table> 
      <tr>        
       <td colspan="2" style="font-size: 16pt;font-weight: bold;color: darkblue">${p.titre}</td> 
      </tr> 
      <tr style="height: 10px"></tr> 
      <tr> 
       <td> 
        <td><img width="220" height="200" **src="http://localhost:8080/uploadimg/pa/imgstore/${p.imgApropos}">**      </td>     
       </td> 
       <td style="font-size: 14pt;text-align: justify;width:710px">${p.apropos}</td>     
      </tr> 
     </table><br> 
      </c:if> 


     <!--image with text under --> 
     <c:if test="${p.imgLargeur == 600}"> 
     <table> 
      <tr>        
       <td colspan="2" style="font-size: 16pt;font-weight: bold;color: darkblue">${p.titre}</td> 
      </tr> 
      <tr style="height: 10px"></tr> 
      <tr> 
       <td>        
        <td><img width="600" height="400" **src="http://localhost:8080/uploadimg/pa/imgstore/${p.imgApropos}">**      </td>     
       </td>       
      </tr> 
      <tr> 
       <td style="font-size: 14pt;text-align: justify;width:710px">${p.apropos}</td> 

      </tr> 
     </table><br> 
     </c:if> 

     <!--Text without image -->  
     <c:if test="${p.imgLargeur == 0}"> 
     <table> 
      <tr>        
       <td colspan="2" style="font-size: 14pt;font-weight: bold;color: darkblue">${p.titre}</td> 
      </tr> 
      <tr style="height: 10px"></tr> 
      <tr> 
       <td style="font-size: 14pt;text-align: justify;width:710px">${p.apropos}</td>      
      </tr> 
     </table><br> 
     </c:if> 
    </c:forEach> 

回答

0

好它應該可以正常工作。查看圖像和數據庫中的擴展名。區分大小寫可能是您的問題的原因。避免使用「http://localhost:8080」,它只能在服務器系統上工作。將 「uploadimg」文件夾放在根文件夾中,並使用「uploadimg/pa/imgstore/$ {p.imgApropos}」來簡單訪問它「