Home >Web Front-end >HTML Tutorial >Image display problem in htm file_html/css_WEB-ITnose

Image display problem in htm file_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:13:04851browse

Here is a Servlet for processing

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();	}}

Here is the code for displaying pictures
  <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>



But the picture cannot be displayed, the picture There is a red XX there, and the relative path is used on it. I don’t know what’s going on. Please solve it... 🎜> Why is there no one? ? ?

If relative doesn’t work, use absolute.
Too bad, and only the absolute path can be written after the SRC. As long as the path returned from the Servlet becomes the format of http://localhost...., it cannot be displayed

>

This is the full path of my image resource, which is in the root directory of the project

D:JavaworkspaceTestAJAXphoto

Write down the address of the image you linked and take a look. Also pay attention to the image format.

//Virtual product list

String[][] shop ={{"Product One","90","photo/photo1.jpg"},
{"Product Two" ,"190","photo/photo2.jpg"},

{"Product 3","290","photo/photo3.jpg"} };

The addresses are all written in the Servlet. Then call it back and change the following src



to the one above, right?
Write the address of the image you linked to and take a look. Also pay attention to the image format

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn