求救!JSP页面无法显示图片和背景!
代码如下:<%@page import="model.BBSmodel"%>
<%@page import="comment.DBconnect"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="bean.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<jsp:useBean class="bean.Userbean" scope="session" id="use" />
<jsp:useBean class="bean.Listbean" scope="session" id="l" />
<%
l=(Listbean)session.getAttribute("l");
use = (Userbean) session.getAttribute("use");
String username = use.getUsername();
int type = Integer.parseInt(request.getParameter("type"));
BBSmodel bm=new BBSmodel();
String type2=bm.getType(type);
ArrayList list=l.getList4();
String _page = request.getParameter("page");
if (_page == null || !_page.matches("\\d+"))
_page = "0";
int page1 = Integer.parseInt(_page);
DBconnect db = new DBconnect();
String name=null;
%>
<style type="text/css">
#tiebiao {
position:absolute;
width:975px;
height:560px;
z-index:1;
left: 25px;
top: 294px;
}
.biao {
margin: 0px;
padding: 0px;
border-top-style: solid;
border-bottom-style: solid;
border-bottom-width: thin;
border-bottom-color: #999;
border-top-width: thin;
border-top-color: #999;
}
#biaoti {
position: absolute;
width: 970px;
height: 26px;
z-index: 5;
top: 107px;
left: 25px;
}
#apDiv1 {
position:absolute;
width:965px;
height:21px;
z-index:6;
left: 27px;
top: 154px;
}
#apDiv2 {
position:absolute;
width:271px;
height:31px;
z-index:1;
left: 699px;
top: 36px;
}
#apDiv3 {
position:absolute;
width:118px;
height:42px;
z-index:7;
left: 26px;
top: 214px;
}
body {
background-image: url("images/index2.jpg");
}
</style>
<script type="text/javascript">
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="tiebiao">
<table width="973" height="38" border="0" class="biao">
<%
for (int i = 0; i < list.size(); i++) {
HashMap map = (HashMap) list.get(i);
%>
<tr>
<td width="397">
<%if(Integer.parseInt((String)map.get("jing"))==1){
%>
<img src="images/jing.png">
<%}else{%>
<img src="images/putong.png">
<%}%>
<%=map.get("title") %></td>
<td width="90" align="center"><%=map.get("username")%></td>
<td width="121"> </td>
<td width="100" align="center"><%=map.get("huifu")%>/<%=map.get("click") %></td>
<td width="243" align="center"><%=map.get("time")%></td>
</tr>
<%}
int total = l.getTotal();
int endpage = 0;
if (total % 10 == 0)
endpage = total / 10 - 1;
else
endpage = total / 10;
%>
</table>
<table width="971" border="0">
<tr>
<td height="30" align="right">
<a href="Tiebeanservlet2?page=0&type=<%=type%>"><img src="images/first.png" width="90" height="35" border="0"></a>
<%if (page1 == 0) {%>
<img src="images/before.png" width="90" height="35">
<%} else {%>
<a href="Tiebeanservlet2?page=<%=page1 - 1%>&type=<%=type%>"><img src="images/before.png" width="90" height="35" border="0"></a>
<%}%>
<%if (page1 == endpage) {%>
<img src="images/next.png" width="90" height="35">
<%}else{%>
<a href="Tiebeanservlet2?page=<%=page1 + 1%>&type=<%=type%>"><img src="images/next.png" width="90" height="35" border="0"></a>
<%} %>
<a href="Tiebeanservlet2?page=<%=endpage%>&type=<%=type%>"><img src="images/last.png" width="90" height="35" border="0"></a>
</td>
</tr>
</table>
<p> </p>
</div>
<div id="biaoti">
<%
if (username == null) {
%>
欢迎您,游客,请 <a href="login.jsp">登录</a>或 <a href="register.jsp">注册</a>
<%
} else {
%>
欢迎您,<%=username%>,您可以选择操作:
<input name="button" type="button" id="button"
onClick="MM_goToURL('parent','people.jsp?username=<%=username%>');return document.MM_returnValue"
value="个人信息">
<input type="button" name="button2" id="button2" value="注销">
<%
}
%>
</div>
<div id="apDiv1"><strong>当前位置:</strong><a href="Indexservlet">论坛首页</a>—><%=type2%></div>
<div id="apDiv3"><a href="post.jsp"><img src="images/add.png" width="119" height="41" border="0"></a></div>
</body>
</html>
图片路径绝对没问题,在myeclipse也能看到,在dreamwevar cs5也能看到,可是用浏览器缺显示不了,背景没有,图片变红×,到底怎么回事?有人帮帮我么? --------------------编程问答-------------------- 浏览器设置 看下 --------------------编程问答-------------------- 这样试试呢? src="${pageContext.request.contextPath}/images/add.png" --------------------编程问答-------------------- 你查看源码看路径对吗 --------------------编程问答-------------------- img 的src前面加上 <%=basePath%> 相错没门 --------------------编程问答-------------------- 还是不行啊,还是不能显示 --------------------编程问答-------------------- 我按照网上这样加了个image文件夹后,把图片连接改成image/图片名就可以了,到底是什么原理呢?背景也是这样 --------------------编程问答-------------------- 图片源路径的什么的都对过了,完全没问题,还是不显示,就是用了那个什么文件夹才搞定了
--------------------编程问答-------------------- 除 --------------------编程问答-------------------- 路过学习 --------------------编程问答-------------------- 现在这个问题解决了吗?怎么做的呢? --------------------编程问答-------------------- <img src=<%=basePath%>/images/你的图片 /> --------------------编程问答-------------------- 我X了,相对路径跟绝对路径都搞清楚了么
补充:Java , Web 开发