【发布时间】:2013-11-19 10:39:22
【问题描述】:
Servlet 程序
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Redirect
*/
@WebServlet("/Redirect")
public class Redirect extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see Servlet#init(ServletConfig)
*/
public void init(ServletConfig config) throws ServletException {
System.out.println("servlet is intialized");
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/jpeg");
request.getRequestDispatcher("/myhtml.jsp").forward(request, response);
}
}
JSP 文件
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="image/jpeg; charset=UTF-8">
<title>NewFile.jsp</title>
</head>
<body>
<a href="http://www.gmail.com"><img src="<%=request.getContextPath()%>/images/gmailimage.jpg" width="100" height="100"></a>
<a href="http://www.yahoomail.com"><img src="<%=request.getContextPath()%>/images/yahooimage.jpg" width="100" height="100"></a>
</body>
</htm
图像文件夹是 --> http://i.stack.imgur.com/558ON.png 。我的问题是 Gmail 图像显示,但 Yahoomail 图像没有显示。结果 --> http://i.stack.imgur.com/dH5AT.png 。为什么这样,有什么问题。建议我提出您的宝贵意见。
【问题讨论】:
-
你应该检查你的图片名称。
-
我提供的正确名称有任何疑问,请查看我提供的链接 i.stack.imgur.com/558ON.png 和 i.stack.imgur.com/dH5AT.png
-
你自己尝试过吗?就像将上面的 yahoo 的 href 标签写到 gmail 的标签上。工作正常吗?
-
如果我用 gmailimage 重命名这两个图像,它会显示完美的 gmail 符号,但是当放置 yahooimage 时,图像没有显示。为什么?
-
这里只有 yahooimage 的问题。那是什么问题?
标签: java image jsp servlets jsp-tags