<%String impath=request.getSession().getServletContext().getRealPath("images/");%>
<td height="147" background="<%=impath %>/top02.gif">我的项目webroot下有个images和login.jsp,images真的有top02.gif,我在页面上
<td  background="images/top02.gif">,不显示图片,
但是<td background="<%=impath %>/top02.gif">却可以显示图片,
但是别人打我的ip加工程名进入页面后看不到图片,右键看图片路径是
file:///F:/workspace/.metadata/.plugins/com.genuitec.eclipse.easie.tomcat.myeclipse/tomcat/webapps/51hiptActing/images/top02.gif 怎么回事呢如何实现我和别人都看得见

解决方案 »

  1.   

    不能用getRealPath()做显示 要用getContextPath()
      

  2.   

    1.把红叉的链接请求直接复制到地址栏按回车可检视地址是否真正准确
    2.检查自己所用的web层解决方案,是否挡住了类似.jpg等请求的发送或类似文件的访问
    比如iis转tomcat时,比如使用struts2时等等。
      

  3.   

    我用struts1.2的,关于第二点不是很明白
      

  4.   

    struts2意思使用拦截器,你图片是在本地么?
      

  5.   


    <td height="147" background="<%=request.getContextPath() %>/top02.gif">
    试试这个