日期:2014-05-17  浏览次数:20575 次

htm文件中图片显示问题
这里是用于处理的一个Servlet
Java code
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CreateTip extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request,response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        //虚拟一个商品列表
        String[][] shop ={{"商品一","90","photo/photo1.jpg"},
                          {"商品二","190","photo/photo2.jpg"},
                          {"商品三","290","photo/photo3.jpg"}    }; 
        
        //获得客户端提交的参数
        int index =Integer.parseInt(request.getParameter("index"));
        
        response.setContentType("text/xml");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        
        //以XML文档形式返回给客户端
        out.println("<shop>");
        out.println("<name>"+shop[index][0]+"</name>");
        out.println("<price>"+shop[index][1]+"</price>");
        out.println("<photo>"+shop[index][2]+"</photo>");
        out.println("</shop>");        

        out.flush();
        out.close();
    }

}


下面是用于显示图片的代码
HTML code
  <body>
    <h2>工具提示</h2><br>
    <hr>
    <a href="#" onmouseover="over(0)" onmouseout="out()">商品一</a><br><br>
    <a href="#" onmouseover="over(1)" onmouseout="out()">商品二</a><br><br>
    <a href="#" onmouseover="over(2)" onmouseout="out()">商品三</a><br><br>
    
    <div id="tip" style="position:absolute;display:none;border:1px;border-style:solid;">
    <TABLE id="tipTable" border="0" bgcolor="#ffffee">
        <TR align="center">
            <TD><img id="photo" src="" height="80" width="80"></TD>
        </TR>
        <TR>
            <TD></TD>
        </TR>
        <TR>
            <TD></TD>
        </TR>
    </TABLE>
    </div>            
  </body>



但是就是无法显示图片,图片那里就一把红XX,上面用的是相对路径啊,不知道怎么回事,求解、、、

------解决方案--------------------
相对不行就用绝对啊
------解决方案--------------------
把你所链接的那个图片地址写上来看看,还要注意图片格式