JSP无法正确显示图片
我的开发环境:eclipse3.3+tomcat5.5+lomboz3.3
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%String name=(String)session.getAttribute("name");
name="1.jpg";
out.print("<img src=/file/"+name+">");
%>
</body>
</html>
只有使用绝对路径时图片才能正常显示,而使用相对路径或者:
out.print("<img src = http://localhost:8080/file/1.jsp">);都不能正常显示。
我的图片文件放在工程file的根目录下。(file/1.jpg)
那位知道的能否告知,谢谢!