首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

iframe不显示图片有关问题

2013-09-18 
iframe不显示图片问题我的代码是这样的:---------index.jsp%@ page languagejava importjava.util.*

iframe不显示图片问题
我的代码是这样的:


---------index.jsp<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<script type="text/javascript">
document.getElementById("if").width =screen.availWidth;
</script>
  </head>
  
  <body>
  <center>
  <iframe id="if" frameborder="0" src="<%=basePath %>mainVisual/mainFrame.jsp"></iframe>
  </center>
  </body>
</html>


然后这是mainFrame.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <style type="text/css">
  </style>
  </head>
  <frameset rows="15%,*" frameborder="no" border="0">
  <frame scrolling="no" src="<%=basePath %>mainVisual/top.jsp" noresize="noresize"/>
  <frame src="<%=basePath %>mainVisual/mainForm/mf_Frame.jsp"/>
  </frameset>
</html>


然后是top.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  
  <body>
  <img alt="iframe不显示图片有关问题" src="<%=basePath%>W3Images/toplogo.jpg">
  </body>
</html>


----------------------分割线---------------------
当我直接写上http://localhost:8080/W3copy/mainVisual/mainFrame.jsp时,
能否正常输出图片!

但是,当我http://localhost:8080/W3copy/是,图片好像被压缩了一样,只显示一点点。



请问,这是怎么回事,该怎么解决呢 ?

注:
1、我的web.xml默认了index.html:<welcome-file>index.jsp</welcome-file>
2、希望回答者能够用代码交流,这样更易理解!谢谢

[解决办法]
ceshi1.html


<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<center>
          <iframe src="ceshi2.html" width="100%" height="400" scrolling="no" frameborder="0"></iframe>
    </center>
</body>
</html>

ceshi2.html

<!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=UTF-8">
<title>Insert title here</title>
</head>
 <frameset rows="15%,*" cols="*">
      <frame scrolling="no" src="ceshi3.html" noresize="noresize"/>
      <frame src="ceshi4.html"/>
  </frameset>
</html>

ceshi3.html

<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<img alt="iframe不显示图片有关问题" src="2012.jpg">
</body>
</html>

ceshi4.html

<!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=UTF-8">


<title>Insert title here</title>
</head>
<body>
下方显示
</body>
</html>


[解决办法]
图片都写成绝对路径试下 <img alt="iframe不显示图片有关问题" src="/W3Images/..">

热点排行