各位高手好!我刚刚接触到JSP开发,很多问题不太懂
    今天想在我的页面中加入一个五星评分的功能,在网上找到了代码,贴到我之前的代码中后,在myeclipse的preview中可以正常显示五星评分效果。但在浏览器中却不能显示图片,鼠标在应该出现五星的位置晃过的时候可以显示打分时应该出现的文字(如很差、不错、还可以、很好、非常好),但就是看不见图片。
    我自己为找出问题作出的尝试:
     1、我检查了tomcat下的文件发现图片在那个目录下也有,应该时成功发布了的。
     2、我新建了一个空JSP文件,将五星评分的代码一点没改原原本本贴进去,发布后,可以成功在浏览器中显示效果。
     3、还有一点要说明,我的五星评分代码就是在csdn上下载的。包含两张五星图片,一个html文件,和一个JS文件,当我把html内容拷贝到我的页面代码(代号为A)后,将五星图片和JS文件都放在同A一个文件夹中。      加入五星评分后,我的页面代码为:
<%@ include file="/WEB-INF/view/include/taglibs.jsp" %>
<%@ page language="java" contentType="text/html;charset=gb2312" import="java.util.*" %><%
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>
    <title>My JSP 'detail.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="styles/main.css">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
      <script type="text/javascript" language="javascript" src="ratingsys.js"></script> 
<style type="text/css">
    #rateStatus{float:left; clear:both; width:100%; height:30px;}
    #rateMe{ clear:both; width:100%;  padding:0px; margin:0px;}
    #rateMe li{float:left;list-style:none;}
    #rateMe li a:hover,
    #rateMe .on{background:url(2.gif) no-repeat;width:30px;height:30px;}
    #rateMe a{float:left;background:url(1.gif) no-repeat;width:30px; height:30px;}
    #ratingSaved{display:none;}
    .saved{color:red; }
    </style> 
  </head>
  
  <body>
      <span id="rateStatus">评分...</span>
    <span id="ratingSaved">评分结果!</span> 
<div id="rateMe" title="评分...">
    <a onclick="rateIt(this)" id="_1" title="较差" onmouseover="rating(this)" onmouseout="off(this)"></a>
    <a onclick="rateIt(this)" id="_2" title="还可以" onmouseover="rating(this)" onmouseout="off(this)"></a>
    <a onclick="rateIt(this)" id="_3" title="好" onmouseover="rating(this)" onmouseout="off(this)"></a>
    <a onclick="rateIt(this)" id="_4" title="相当好" onmouseover="rating(this)" onmouseout="off(this)"></a>
    <a onclick="rateIt(this)" id="_5" title="好极了" onmouseover="rating(this)" onmouseout="off(this)"></a>
</div>
 <center>
 <br>
 <br> 
   论文详细信息. <br>
    <TABLE>
    <TR ><td width="80"><LABEL>论文名</LABEL></td><td><LABEL><c:out value="${bookinfo.name}"/></LABEL></td></TR>
   
    <TR><td><LABEL>作者</LABEL></td><td> <LABEL><c:out value="${bookinfo.author}"/></LABEL></td></TR>
    <TR><td><LABEL>出版社</LABEL></td><td><LABEL><c:out value="${bookinfo.press}"/></LABEL></td></TR>
    <TR><td><LABEL>其他信息</LABEL></td><td><LABEL><c:out value="${bookinfo.price}"/></LABEL></td></TR>
    <%-- <TR> <td><LABEL>售价</LABEL></td><td><LABEL><c:out value="${bookinfo.saleprice}"/></LABEL></td></TR>--%>
    <TR><td><LABEL>简介</LABEL></td><td><LABEL><c:out value="${bookinfo.descript}"/></LABEL></td></TR>
    <TR><td><LABEL>论文内容</LABEL></td><td> <textarea name="content" cols="100" rows="10" readonly="true"><c:out value="${bookinfo.content}"/></textarea></td></TR>
    <TR><td>    </td></TR>
    <TR><td align="center">
   
    <a href="javascript:history.back()">返回</a>
    
    </td></TR>
    </TABLE>
   </center>
  
  </body>
</html>    恳请各位帮助小妹解决这个问题!非常感谢!

解决方案 »

  1.   

    不是放在js文件的那个目录下,应该放在你的页面文件的那个目录下,就是那个html文件的那个目录下
      

  2.   

    谢谢您的回复,我将图片、JS文件、还有加入了五星评分代码的我的JSP页面都放在了一个目录下。不知道您说的是不是这个意思?
      

  3.   

    我的页面确实有服务器跳转,但是我不太明白添加的五星评分代码中的这两句:
      #rateMe .on{background:url(2.gif) no-repeat;width:30px;height:30px;}
      #rateMe a{float:left;background:url(1.gif) no-repeat;width:30px; height:30px;}
    加入图片是在这里进行的,我不明白这个url是什么意思。难道就是指使用相对路径,默认为与本页面在一个目录下?如果使用绝对路径就是去掉这个"url",变成“我的项目名称/***/1.jif”么?
    谢谢您了
      

  4.   

    我的页面确实有服务器跳转,但是我不太明白添加的五星评分代码中的这两句:
      #rateMe .on{background:url(2.gif) no-repeat;width:30px;height:30px;}
      #rateMe a{float:left;background:url(1.gif) no-repeat;width:30px; height:30px;}
    加入图片是在这里进行的,我不明白这个url是什么意思。难道就是指使用相对路径,默认为与本页面在一个目录下?如果使用绝对路径就是去掉这个"url",变成“我的项目名称/***/1.jif”么?
    谢谢您了
      

  5.   

    图片不要放在WEB-INF下,读不到很正常