2016-06-08 61 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}”来简单访问它“